summaryrefslogtreecommitdiffstats
path: root/wp-admin
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-02-15 13:19:12 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-02-15 13:19:12 +0000
commit8752f7651d737da0dbe86065e708347a58b40d61 (patch)
treeac80c1eb849760d123d729ffb33fb8a9dc1742db /wp-admin
parent982f28611561556403f1c1004ad41f3253205e0e (diff)
downloadwordpress-mu-8752f7651d737da0dbe86065e708347a58b40d61.tar.gz
wordpress-mu-8752f7651d737da0dbe86065e708347a58b40d61.tar.xz
wordpress-mu-8752f7651d737da0dbe86065e708347a58b40d61.zip
WP Merge to rev 4887
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@888 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin')
-rw-r--r--wp-admin/admin-ajax.php2
-rw-r--r--wp-admin/admin-functions.php22
-rw-r--r--wp-admin/plugin-editor.php53
-rw-r--r--wp-admin/upgrade.php29
4 files changed, 87 insertions, 19 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index ece9539..c7b51d5 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -155,7 +155,7 @@ case 'add-meta' :
if ( !current_user_can( 'edit_post', $id ) )
die('-1');
if ( $id < 0 ) {
- $now = current_time('timestamp');
+ $now = current_time('timestamp', 1);
if ( $pid = wp_insert_post( array(
'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
) ) )
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 83e0e74..583aca9 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -22,6 +22,7 @@ function wp_write_post() {
// Check for autosave collisions
+ $temp_id = false;
if ( isset($_POST['temp_ID']) ) {
$temp_id = (int) $_POST['temp_ID'];
if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
@@ -33,7 +34,6 @@ function wp_write_post() {
if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
$_POST['post_ID'] = $draft_ids[$temp_id];
unset($_POST['temp_ID']);
- relocate_children( $temp_id, $_POST['post_ID'] );
update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
return edit_post();
}
@@ -112,9 +112,15 @@ function wp_write_post() {
add_meta( $post_ID );
// Reunite any orphaned attachments with their parent
+ if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+ $draft_ids = array();
+ if ( $draft_temp_id = 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 ) {
- relocate_children( $temp_id, $post_ID );
$draft_ids[$temp_id] = $post_ID;
update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
}
@@ -139,14 +145,14 @@ function fix_attachment_links( $post_ID ) {
$post = & get_post( $post_ID, ARRAY_A );
- $search = "#<a[^>]+rel=('|\" )[^'\"]*attachment[^>]*>#ie";
+ $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";
+ $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
foreach ( $anchor_matches[0] as $anchor ) {
if ( 0 == preg_match( $search, $anchor, $id_matches ) )
continue;
@@ -279,7 +285,13 @@ function edit_post() {
add_meta( $post_ID );
- wp_update_post( $_POST);
+ wp_update_post( $_POST );
+
+ // Reunite any orphaned attachments with their parent
+ if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+ $draft_ids = array();
+ if ( $draft_temp_id = 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 );
diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php
index 3020b48..e9fc912 100644
--- a/wp-admin/plugin-editor.php
+++ b/wp-admin/plugin-editor.php
@@ -31,6 +31,17 @@ case 'update':
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
+
+ // Deactivate so we can test it.
+ $current = get_option('active_plugins');
+ if ( in_array($file, $current) || isset($_POST['phperror']) ) {
+ if ( in_array($file, $current) ) {
+ array_splice($current, array_search( $file, $current), 1 ); // Array-fu!
+ update_option('active_plugins', $current);
+ }
+ wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1"));
+ exit();
+ }
wp_redirect("plugin-editor.php?file=$file&a=te");
} else {
wp_redirect("plugin-editor.php?file=$file");
@@ -45,6 +56,24 @@ default:
if ( !current_user_can('edit_plugins') )
wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>');
+ if ( $_GET['liveupdate'] ) {
+ check_admin_referer('edit-plugin-test_' . $file);
+ $current = get_option('active_plugins');
+ $plugin = $file;
+ if ( validate_file($plugin) )
+ wp_die(__('Invalid plugin.'));
+ if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
+ wp_die(__('Plugin file does not exist.'));
+ if (!in_array($plugin, $current)) {
+ wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error
+ @include(ABSPATH . PLUGINDIR . '/' . $plugin);
+ $current[] = $plugin;
+ sort($current);
+ update_option('active_plugins', $current);
+ }
+ wp_redirect("plugin-editor.php?file=$file&a=te");
+ }
+
require_once('admin-header.php');
update_recently_edited(PLUGINDIR . "/$file");
@@ -61,13 +90,23 @@ default:
?>
<?php if (isset($_GET['a'])) : ?>
<div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
+<?php elseif (isset($_GET['phperror'])) : ?>
+ <div id="message" class="updated fade"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p></div>
<?php endif; ?>
<div class="wrap">
<?php
- if (is_writeable($real_file)) {
- echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
+ if ( in_array($file, (array) get_option('active_plugins')) ) {
+ if (is_writeable($real_file)) {
+ echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (active)'), $file) . '</h2>';
+ } else {
+ echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (active)'), $file) . '</h2>';
+ }
} else {
- echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
+ if (is_writeable($real_file)) {
+ echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (inactive)'), $file) . '</h2>';
+ } else {
+ echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file) . '</h2>';
+ }
}
?>
<div id="templateside">
@@ -91,9 +130,15 @@ if ($plugin_files) :
<input type="hidden" name="file" value="<?php echo $file ?>" />
</div>
<?php if ( is_writeable($real_file) ) : ?>
+ <?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>
+ <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
- echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
+ if ( isset($_GET['phperror']) )
+ echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' value='" . __('Update File and Attempt to Reactivate &raquo;') . "' tabindex='2' />";
+ else
+ echo "<input type='submit' name='submit' value='" . __('Update File &raquo;') . "' tabindex='2' />";
?>
</p>
<?php else : ?>
diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php
index 3e1b740..7cd81be 100644
--- a/wp-admin/upgrade.php
+++ b/wp-admin/upgrade.php
@@ -8,7 +8,7 @@ timer_start();
require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
if (isset($_GET['step']))
- $step = $_GET['step'];
+ $step = (int) $_GET['step'];
else
$step = 0;
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
@@ -25,12 +25,21 @@ else
</head>
<body>
<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
-<?php
-switch($step) {
+
+<?php if ( get_option('db_version') == $wp_db_version ) : ?>
+
+<h2><?php _e('No Upgrade Required'); ?></h2>
+<p><?php _e('Your WordPress database is already up-to-date!'); ?></p>
+<h2 class="step"><a href="<?php echo get_option('home'); ?>/"><?php _e('Continue &raquo;'); ?></a></h2>
+
+<?php else :
+switch($step) :
case 0:
$goback = attribute_escape(stripslashes(wp_get_referer()));
-?>
-<p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p>
+?>
+<h2><?php _e('Database Upgrade Required'); ?></h2>
+<p><?php _e('Your WordPress database is out-of-date, and must be upgraded before you can continue.'); ?></p>
+<p><?php _e('The upgrade process may take a while, so please be patient.'); ?></p>
<h2 class="step"><a href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
<?php
break;
@@ -38,7 +47,7 @@ switch($step) {
wp_upgrade();
if ( empty( $_GET['backto'] ) )
- $backto = __get_option('home');
+ $backto = __get_option('home') . '/';
else
$backto = attribute_escape(stripslashes($_GET['backto']));
if( $wpdb->get_row( "SELECT blog_id FROM wp_blog_versions WHERE blog_id = '{$wpdb->blogid}'" ) ) {
@@ -47,8 +56,9 @@ switch($step) {
$wpdb->query( "INSERT INTO wp_blog_versions ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
}
?>
-<h2><?php _e('Step 1'); ?></h2>
- <p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"), $backto); ?></p>
+<h2><?php _e('Upgrade Complete'); ?></h2>
+ <p><?php _e('Your WordPress database has been successfully upgraded!'); ?></p>
+ <h2 class="step"><a href="<?php echo $backto; ?>"><?php _e('Continue &raquo;'); ?></a></h2>
<!--
<pre>
@@ -60,7 +70,8 @@ switch($step) {
<?php
break;
-}
+endswitch;
+endif;
?>
</body>
</html>