diff options
-rw-r--r-- | wp-admin/admin-ajax.php | 2 | ||||
-rw-r--r-- | wp-admin/admin-functions.php | 22 | ||||
-rw-r--r-- | wp-admin/plugin-editor.php | 53 | ||||
-rw-r--r-- | wp-admin/upgrade.php | 29 | ||||
-rw-r--r-- | wp-includes/category-template.php | 4 | ||||
-rw-r--r-- | wp-includes/comment-template.php | 2 | ||||
-rw-r--r-- | wp-includes/feed.php | 6 | ||||
-rw-r--r-- | wp-includes/functions.php | 4 | ||||
-rw-r--r-- | wp-includes/link-template.php | 35 | ||||
-rw-r--r-- | wp-includes/pluggable.php | 4 | ||||
-rw-r--r-- | wp-includes/rewrite.php | 2 |
11 files changed, 126 insertions, 37 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 »') . "' 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 »') . "' tabindex='2' />"; + else + echo "<input type='submit' name='submit' value='" . __('Update File »') . "' 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 »'); ?></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&backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress »'); ?></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 »'); ?></a></h2> <!-- <pre> @@ -60,7 +70,8 @@ switch($step) { <?php break; -} +endswitch; +endif; ?> </body> </html> diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 1ca0743..fed3043 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -35,10 +35,10 @@ function get_category_link($category_id) { $category->category_parent = 0; if ( $parent = $category->category_parent ) - $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/'; + $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename; $catlink = str_replace('%category%', $category_nicename, $catlink); - $catlink = get_option('home') . trailingslashit($catlink); + $catlink = get_option('home') . user_trailingslashit($catlink); } return apply_filters('category_link', $catlink, $category_id); } diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 38587da..d57aff5 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -226,7 +226,7 @@ function get_trackback_url() { $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id; if ( '' != get_option('permalink_structure') ) - $tb_url = trailingslashit(get_permalink()) . 'trackback/'; + $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback'); return $tb_url; } diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 6c57fc5..04f54d9 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -99,7 +99,7 @@ function comments_rss($commentsrssfilename = '') { global $id; if ( '' != get_option('permalink_structure') ) - $url = trailingslashit( get_permalink() ) . 'feed/'; + $url = trailingslashit( get_permalink() ) . user_trailingslashit('feed'); else $url = get_option('home') . "/$commentsrssfilename?feed=rss2&p=$id"; @@ -115,7 +115,7 @@ function get_author_rss_link($echo = false, $author_id, $author_nicename) { $link = get_option('home') . '?feed=rss2&author=' . $author_id; } else { $link = get_author_posts_url($author_id, $author_nicename); - $link = $link . "feed/"; + $link = $link . user_trailingslashit('feed'); } $link = apply_filters('author_feed_link', $link); @@ -133,7 +133,7 @@ function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { $link = get_option('home') . '?feed=rss2&cat=' . $cat_ID; } else { $link = get_category_link($cat_ID); - $link = $link . "feed/"; + $link = $link . user_trailingslashit('feed/'); } $link = apply_filters('category_feed_link', $link); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 3ab25e5..afd5470 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1301,9 +1301,9 @@ function wp_nonce_ays($action) { $html .= "\t\t<input type='hidden' name='" . attribute_escape(urldecode($k)) . "' value='" . attribute_escape(urldecode($v)) . "' />\n"; } $html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n"; - $html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . wp_explain_nonce($action) . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n"; + $html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . wp_specialchars(wp_explain_nonce($action)) . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n"; } else { - $html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . wp_explain_nonce($action) . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . add_query_arg( '_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'] ) . "'>" . __('Yes') . "</a></p>\n\t</div>\n"; + $html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . wp_specialchars(wp_explain_nonce($action)) . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . add_query_arg( '_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'] ) . "'>" . __('Yes') . "</a></p>\n\t</div>\n"; } $html .= "</body>\n</html>"; wp_die($html, $title); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 20b9132..f576129 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -11,6 +11,23 @@ function permalink_link() { // For backwards compatibility } +/** + * Conditionally adds a trailing slash if the permalink structure + * has a trailing slash, strips the trailing slash if not + * @global object Uses $wp_rewrite + * @param $string string a URL with or without a trailing slash + * @return string + */ +function user_trailingslashit($string) { + global $wp_rewrite; + if ( $wp_rewrite->use_trailing_slashes ) + $string = trailingslashit($string); + else + $string = preg_replace('|/$|', '', $string); // untrailing slash + return $string; +} + + function permalink_anchor($mode = 'id') { global $post; switch ( strtolower($mode) ) { @@ -116,7 +133,8 @@ function _get_page_link( $id = false ) { if ( '' != $pagestruct && 'draft' != $post->post_status ) { $link = get_page_uri($id); $link = str_replace('%pagename%', $link, $pagestruct); - $link = get_option('home') . "/$link/"; + $link = get_option('home') . "/$link"; + $link = user_trailingslashit($link); } else { $link = get_option('home') . "/?page_id=$id"; } @@ -158,7 +176,7 @@ function get_year_link($year) { $yearlink = $wp_rewrite->get_year_permastruct(); if ( !empty($yearlink) ) { $yearlink = str_replace('%year%', $year, $yearlink); - return apply_filters('year_link', get_option('home') . trailingslashit($yearlink), $year); + return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink), $year); } else { return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year); } @@ -174,7 +192,7 @@ function get_month_link($year, $month) { if ( !empty($monthlink) ) { $monthlink = str_replace('%year%', $year, $monthlink); $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); - return apply_filters('month_link', get_option('home') . trailingslashit($monthlink), $year, $month); + return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink), $year, $month); } else { return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month); } @@ -194,7 +212,7 @@ function get_day_link($year, $month, $day) { $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', get_option('home') . trailingslashit($daylink), $year, $month, $day); + return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink), $year, $month, $day); } else { return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); } @@ -217,8 +235,8 @@ function get_feed_link($feed='rss2') { $feed = ''; $permalink = str_replace('%feed%', $feed, $permalink); - $permalink = preg_replace('#/+#', '/', "/$permalink/"); - $output = get_option('home') . $permalink; + $permalink = preg_replace('#/+#', '/', "/$permalink"); + $output = get_option('home') . user_trailingslashit($permalink); } else { if ( false !== strpos($feed, 'comments_') ) $feed = str_replace('comments_', 'comments-', $feed); @@ -435,12 +453,13 @@ function get_pagenum_link($pagenum = 1) { $qstr = preg_replace('|^/+|', '', $qstr); if ( $permalink ) - $qstr = trailingslashit($qstr); + $qstr = user_trailingslashit($qstr); $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_option('home') ) . $qstr ); // showing /page/1/ or ?paged=1 is redundant if ( 1 === $pagenum ) { - $qstr = str_replace('page/1/', '', $qstr); // for mod_rewrite style + $qstr = str_replace(user_trailingslashit('index.php/page/1'), '', $qstr); // for PATHINFO style + $qstr = str_replace(user_trailingslashit('page/1'), '', $qstr); // for mod_rewrite style $qstr = remove_query_arg('paged', $qstr); // for query style } return $qstr; diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 0442789..9815607 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -378,8 +378,8 @@ function wp_notify_postauthor($comment_id, $comment_type='') { $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( __('To delete this comment, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n"; - $notify_message .= sprintf( __('To mark this comment as spam, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n"; + $notify_message .= sprintf( __('Delete it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n"; + $notify_message .= sprintf( __('Spam it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n"; $admin_email = get_option('admin_email'); diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 2411787..a8af33a 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -148,6 +148,7 @@ function url_to_postid($url) { class WP_Rewrite {
var $permalink_structure;
+ var $use_trailing_slashes;
var $category_base;
var $category_structure;
var $author_base = 'author';
@@ -876,6 +877,7 @@ class WP_Rewrite { unset($this->search_structure);
unset($this->feed_structure);
unset($this->comment_feed_structure);
+ $this->use_trailing_slashes = ( substr($this->permalink_structure, -1, 1) == '/' ) ? true : false;
}
function set_permalink_structure($permalink_structure) {
|