summaryrefslogtreecommitdiffstats
path: root/wp-includes
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes')
-rw-r--r--wp-includes/bookmark-template.php9
-rw-r--r--wp-includes/category-template.php10
-rw-r--r--wp-includes/cron.php9
-rw-r--r--wp-includes/default-filters.php3
-rw-r--r--wp-includes/formatting.php18
-rw-r--r--wp-includes/functions.php140
-rw-r--r--wp-includes/general-template.php43
-rw-r--r--wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js5
-rw-r--r--wp-includes/js/tinymce/tiny_mce_config.php4
-rw-r--r--wp-includes/l10n.php8
-rw-r--r--wp-includes/pluggable.php2
-rw-r--r--wp-includes/plugin.php22
-rw-r--r--wp-includes/post-template.php5
-rw-r--r--wp-includes/post.php80
-rw-r--r--wp-includes/script-loader.php4
-rw-r--r--wp-includes/vars.php2
-rw-r--r--wp-includes/wpmu-functions.php149
17 files changed, 262 insertions, 251 deletions
diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php
index 446ea46..c5c2505 100644
--- a/wp-includes/bookmark-template.php
+++ b/wp-includes/bookmark-template.php
@@ -319,12 +319,15 @@ function wp_list_bookmarks($args = '') {
$defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, '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');
+ 'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat');
$r = array_merge($defaults, $r);
extract($r);
$output = '';
+ if ( is_array($class) )
+ $class = trim(join(' ', $class));
+
if ( $categorize ) {
//Split the bookmarks into ul's for each category
$cats = get_categories("type=link&category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0");
@@ -333,7 +336,7 @@ function wp_list_bookmarks($args = '') {
$bookmarks = get_bookmarks("limit=$limit&category={$cat->cat_ID}&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_inivisible&show_updated=$show_updated");
if ( empty($bookmarks) )
continue;
- $output .= "<li id='linkcat-$cat->cat_ID' class='linkcat'>$title_before$cat->cat_name$title_after\n\t<ul>\n";
+ $output .= "<li id='linkcat-$cat->cat_ID' class='$class'>$title_before$cat->cat_name$title_after\n\t<ul>\n";
$output .= _walk_bookmarks($bookmarks, $r);
$output .= "\n\t</ul>\n</li>\n";
}
@@ -342,7 +345,7 @@ function wp_list_bookmarks($args = '') {
$bookmarks = get_bookmarks("limit=$limit&category=$category&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_inivisible&show_updated=$show_updated");
if ( !empty($bookmarks) ) {
- $output .= "<li id='linkuncat' class='linkcat'>$title_before$title_li$title_after\n\t<ul>\n";
+ $output .= "<li id='linkuncat' class='$class'>$title_before$title_li$title_after\n\t<ul>\n";
$output .= _walk_bookmarks($bookmarks, $r);
$output .= "\n\t</ul>\n</li>\n";
}
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
index e2a8c69..c15a4f8 100644
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -60,15 +60,15 @@ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename =
}
function get_the_category($id = false) {
-global $post, $category_cache;
+global $post, $category_cache, $blog_id;
if ( !$id )
$id = $post->ID;
- if ( !isset($category_cache[$id]) )
+ if ( !isset($category_cache[$blog_id][$id]) )
update_post_category_cache($id);
- $categories = $category_cache[$id];
+ $categories = $category_cache[$blog_id][$id];
if ( !empty($categories) )
sort($categories);
@@ -140,9 +140,9 @@ function get_the_category_list($separator = '', $parents='') {
}
function in_category($category) { // Check if the current post is in the given category
- global $category_cache, $post;
+ global $category_cache, $post, $blog_id;
- if ( isset( $category_cache[$post->ID][$category] ) )
+ if ( isset( $category_cache[$blog_id][$post->ID][$category] ) )
return true;
else
return false;
diff --git a/wp-includes/cron.php b/wp-includes/cron.php
index 6731e70..2310b40 100644
--- a/wp-includes/cron.php
+++ b/wp-includes/cron.php
@@ -1,7 +1,6 @@
<?php
-function wp_schedule_single_event( $timestamp, $hook ) {
- $args = array_slice( func_get_args(), 2 );
+function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
$crons = _get_cron_array();
$key = md5(serialize($args));
$crons[$timestamp][$hook][$key] = array( 'schedule' => false, 'args' => $args );
@@ -9,8 +8,7 @@ function wp_schedule_single_event( $timestamp, $hook ) {
_set_cron_array( $crons );
}
-function wp_schedule_event( $timestamp, $recurrence, $hook ) {
- $args = array_slice( func_get_args(), 3 );
+function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
$key = md5(serialize($args));
@@ -21,8 +19,7 @@ function wp_schedule_event( $timestamp, $recurrence, $hook ) {
_set_cron_array( $crons );
}
-function wp_reschedule_event( $timestamp, $recurrence, $hook ) {
- $args = array_slice( func_get_args(), 3 );
+function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
$key = md5(serialize($args));
diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
index ad60242..4dd3f7d 100644
--- a/wp-includes/default-filters.php
+++ b/wp-includes/default-filters.php
@@ -145,6 +145,7 @@ add_filter('option_ping_sites', 'privacy_ping_filter');
add_filter('option_blog_charset', 'wp_specialchars');
add_filter('mce_plugins', '_mce_load_rtl_plugin');
add_filter('mce_buttons', '_mce_add_direction_buttons');
+add_filter('tiny_mce_config_url', '_mce_config_url');
// Actions
add_action('wp_head', 'rsd_link');
@@ -152,7 +153,7 @@ add_action('wp_head', 'locale_stylesheet');
add_action('publish_future_post', 'wp_publish_post', 10, 1);
add_action('wp_head', 'noindex', 1);
add_action('wp_head', 'wp_print_scripts');
-if(!defined('DOING_CRON'))
+if(!defined('DOING_CRON') && !strstr( $_SERVER['REQUEST_URI'], 'wp-cron.php' ) )
add_action('init', 'wp_cron');
add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
add_action('do_feed_rss', 'do_feed_rss', 10, 1);
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index 11f0067..5c96044 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -618,14 +618,7 @@ function convert_smilies($text) {
if (get_option('use_smilies')) {
// 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($wp_smiliessearch, $wp_smiliesreplace, $content);
- }
- $output .= $content;
- }
+ $output = implode('', preg_replace($wp_smiliessearch, $wp_smiliesreplace, $textarr));
} else {
// return default text.
$output = $text;
@@ -1070,11 +1063,8 @@ function js_escape($text) {
return preg_replace("/\r?\n/", "\\n", addslashes($text));
}
-function wp_make_link_relative( $link, $base = '' ) {
- if ( !$base )
- $base = get_option( 'home' );
- if ( 0 === strpos($link, $base) )
- $link = substr_replace($link, '', 0, strlen($base));
- return $link;
+function wp_make_link_relative( $link ) {
+ return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
}
+
?>
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 1762e89..6dc1f7f 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -106,10 +106,10 @@ function get_weekstartend($mysqlstring, $start_of_week) {
}
function get_lastpostdate($timezone = 'server') {
- global $cache_lastpostdate, $pagenow, $wpdb;
+ global $cache_lastpostdate, $pagenow, $wpdb, $blog_id;
$add_seconds_blog = get_option('gmt_offset') * 3600;
$add_seconds_server = date('Z');
- if ( !isset($cache_lastpostdate[$timezone]) ) {
+ if ( !isset($cache_lastpostdate[$blog_id][$timezone]) ) {
switch(strtolower($timezone)) {
case 'gmt':
$lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
@@ -121,18 +121,18 @@ function get_lastpostdate($timezone = 'server') {
$lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
break;
}
- $cache_lastpostdate[$timezone] = $lastpostdate;
+ $cache_lastpostdate[$blog_id][$timezone] = $lastpostdate;
} else {
- $lastpostdate = $cache_lastpostdate[$timezone];
+ $lastpostdate = $cache_lastpostdate[$blog_id][$timezone];
}
return $lastpostdate;
}
function get_lastpostmodified($timezone = 'server') {
- global $cache_lastpostmodified, $pagenow, $wpdb;
+ global $cache_lastpostmodified, $pagenow, $wpdb, $blog_id;
$add_seconds_blog = get_option('gmt_offset') * 3600;
$add_seconds_server = date('Z');
- if ( !isset($cache_lastpostmodified[$timezone]) ) {
+ if ( !isset($cache_lastpostmodified[$blog_id][$timezone]) ) {
switch(strtolower($timezone)) {
case 'gmt':
$lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
@@ -148,9 +148,9 @@ function get_lastpostmodified($timezone = 'server') {
if ( $lastpostdate > $lastpostmodified ) {
$lastpostmodified = $lastpostdate;
}
- $cache_lastpostmodified[$timezone] = $lastpostmodified;
+ $cache_lastpostmodified[$blog_id][$timezone] = $lastpostmodified;
} else {
- $lastpostmodified = $cache_lastpostmodified[$timezone];
+ $lastpostmodified = $cache_lastpostmodified[$blog_id][$timezone];
}
return $lastpostmodified;
}
@@ -204,7 +204,7 @@ function get_option($setting) {
$value = $row->option_value;
wp_cache_set($setting, ($value=='')?'emptystringindb':$value, 'options');
} else {
- wp_cache_set($setting, 'novalueindb', 'options', 5);
+ wp_cache_set($setting, 'novalueindb', 'options');
return false;
}
}
@@ -491,41 +491,41 @@ function is_new_day() {
}
function update_post_cache(&$posts) {
- global $post_cache;
+ global $post_cache, $blog_id;
if ( !$posts )
return;
for ($i = 0; $i < count($posts); $i++) {
- $post_cache[$posts[$i]->ID] = &$posts[$i];
+ $post_cache[$blog_id][$posts[$i]->ID] = &$posts[$i];
}
}
function clean_post_cache($id) {
- global $post_cache;
+ global $post_cache, $blog_id;
- if ( isset( $post_cache[$id] ) )
- unset( $post_cache[$id] );
+ if ( isset( $post_cache[$blog_id][$id] ) )
+ unset( $post_cache[$blog_id][$id] );
}
function update_page_cache(&$pages) {
- global $page_cache;
+ global $page_cache, $blog_id;
if ( !$pages )
return;
for ($i = 0; $i < count($pages); $i++) {
- $page_cache[$pages[$i]->ID] = &$pages[$i];
+ $page_cache[$blog_id][$pages[$i]->ID] = &$pages[$i];
wp_cache_add($pages[$i]->ID, $pages[$i], 'pages');
}
}
function clean_page_cache($id) {
- global $page_cache, $wpdb;
+ global $page_cache, $wpdb, $blog_id;
- if ( isset( $page_cache[$id] ) )
- unset( $page_cache[$id] );
+ if ( isset( $page_cache[$blog_id][$id] ) )
+ unset( $page_cache[$blog_id][$id] );
$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type='page'");
wp_cache_delete('all_page_ids','pages');
@@ -533,7 +533,7 @@ function clean_page_cache($id) {
}
function update_post_category_cache($post_ids) {
- global $wpdb, $category_cache;
+ global $wpdb, $category_cache, $blog_id;
if ( empty($post_ids) )
return;
@@ -547,12 +547,12 @@ function update_post_category_cache($post_ids) {
return;
foreach ($dogs as $catt)
- $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
+ $category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
}
function update_post_caches(&$posts) {
global $post_cache, $category_cache, $post_meta_cache;
- global $wpdb;
+ global $wpdb, $blog_id;
// No point in doing all this work if we didn't match any posts.
if ( !$posts )
@@ -561,7 +561,7 @@ function update_post_caches(&$posts) {
// Get the categories for all the posts
for ($i = 0; $i < count($posts); $i++) {
$post_id_array[] = $posts[$i]->ID;
- $post_cache[$posts[$i]->ID] = &$posts[$i];
+ $post_cache[$blog_id][$posts[$i]->ID] = &$posts[$i];
}
$post_id_list = implode(',', $post_id_array);
@@ -571,20 +571,20 @@ function update_post_caches(&$posts) {
// Get post-meta info
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
// Change from flat structure to hierarchical:
- $post_meta_cache = array();
+ $post_meta_cache[$blog_id] = array();
foreach ($meta_list as $metarow) {
$mpid = $metarow['post_id'];
$mkey = $metarow['meta_key'];
$mval = $metarow['meta_value'];
// Force subkeys to be array type:
- if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) )
- $post_meta_cache[$mpid] = array();
- if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) )
- $post_meta_cache[$mpid]["$mkey"] = array();
+ if ( !isset($post_meta_cache[$blog_id][$mpid]) || !is_array($post_meta_cache[$blog_id][$mpid]) )
+ $post_meta_cache[$blog_id][$mpid] = array();
+ if ( !isset($post_meta_cache[$blog_id][$mpid]["$mkey"]) || !is_array($post_meta_cache[$blog_id][$mpid]["$mkey"]) )
+ $post_meta_cache[$blog_id][$mpid]["$mkey"] = array();
// Add a value to the current pid/key:
- $post_meta_cache[$mpid][$mkey][] = $mval;
+ $post_meta_cache[$blog_id][$mpid][$mkey][] = $mval;
}
}
}
@@ -812,6 +812,7 @@ function do_feed_atom() {
function do_robots() {
global $current_blog;
do_action('do_robotstxt');
+
if ( '0' == $current_blog->public ) {
echo "User-agent: *\n";
echo "Disallow: /\n";
@@ -1127,62 +1128,31 @@ function wp_nonce_ays($action) {
}
function wp_die($message, $title = '') {
+ global $wp_locale;
+
header('Content-Type: text/html; charset=utf-8');
if ( empty($title) )
$title = __('WordPress &rsaquo; Error');
if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
- $logo_src = 'images/wordpress-logo.png';
+ $admin_dir = '';
else
- $logo_src = 'wp-admin/images/wordpress-logo.png';
+ $admin_dir = 'wp-admin/';
?>
<!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">
+<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<title><?php echo $title ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <style media="screen" type="text/css">
- <!--
- html {
- background: #eee;
- }
- body {
- background: #fff;
- color: #000;
- font-family: Georgia, "Times New Roman", Times, serif;
- margin-left: 25%;
- margin-right: 25%;
- padding: .2em 2em;
- }
-
- h1 {
- color: #006;
- font-size: 18px;
- font-weight: lighter;
- }
-
- h2 {
- font-size: 16px;
- }
-
- p, li, dt {
- line-height: 140%;
- padding-bottom: 2px;
- }
-
- ul, ol {
- padding: 5px 5px 5px 20px;
- }
- #logo {
- margin-bottom: 2em;
- }
- -->
- </style>
+ <link rel="stylesheet" href="<?php echo $admin_dir; ?>install.css" type="text/css" />
+<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
+ <link rel="stylesheet" href="<?php echo $admin_dir; ?>install-rtl.css" type="text/css" />
+<?php endif; ?>
</head>
<body>
- <h1 id="logo"><img alt="WordPress" src="<?php echo $logo_src; ?>" /></h1>
+ <h1 id="logo"><img alt="WordPress" src="<?php echo $admin_dir; ?>images/wordpress-logo.png" /></h1>
<p><?php echo $message; ?></p>
</body>
</html>
@@ -1191,10 +1161,24 @@ function wp_die($message, $title = '') {
die();
}
+function _mce_config_url($url) {
+ global $wp_locale;
+
+ if ( 'rtl' == $wp_locale->text_direction )
+ $url = add_query_arg('mce_text_direction', 'rtl', $url);
+
+ return $url;
+}
+
function _mce_set_direction() {
global $wp_locale;
- if ('rtl' == $wp_locale->text_direction) {
+ if ( isset($_GET['mce_text_direction']) && 'rtl' == $_GET['mce_text_direction'] )
+ $dir = 'rtl';
+ else
+ $dir = $wp_locale->text_direction;
+
+ if ( 'rtl' == $dir ) {
echo 'directionality : "rtl" ,';
echo 'theme_advanced_toolbar_align : "right" ,';
}
@@ -1203,7 +1187,12 @@ function _mce_set_direction() {
function _mce_load_rtl_plugin($input) {
global $wp_locale;
- if ('rtl' == $wp_locale->text_direction)
+ if ( isset($_GET['mce_text_direction']) && 'rtl' == $_GET['mce_text_direction'] )
+ $dir = 'rtl';
+ else
+ $dir = $wp_locale->text_direction;
+
+ if ( 'rtl' == $dir )
$input[] = 'directionality';
return $input;
@@ -1212,7 +1201,12 @@ function _mce_load_rtl_plugin($input) {
function _mce_add_direction_buttons($input) {
global $wp_locale;
- if ('rtl' == $wp_locale->text_direction) {
+ if ( isset($_GET['mce_text_direction']) && 'rtl' == $_GET['mce_text_direction'] )
+ $dir = 'rtl';
+ else
+ $dir = $wp_locale->text_direction;
+
+ if ( 'rtl' == $dir ) {
$new_buttons = array('separator', 'ltr', 'rtl');
$input = array_merge($input, $new_buttons);
}
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index ab68a5d..d5c2e49 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -206,7 +206,7 @@ function wp_title($sep = '&raquo;', $display = true) {
}
$prefix = '';
- if ( isset($title) )
+ if ( !empty($title) )
$prefix = " $sep ";
$title = $prefix . $title;
@@ -333,7 +333,11 @@ function wp_get_archives($args = '') {
$add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
if ( 'monthly' == $type ) {
- $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
+ $arcresults = wp_cache_get( md5('archives' . $type . $limit), 'general');
+ if ( !$arcresults ) {
+ $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
+ wp_cache_set( md5('archives' . $type . $limit), $arcresults, 'general', 600 );
+ }
if ( $arcresults ) {
$afterafter = $after;
foreach ( $arcresults as $arcresult ) {
@@ -452,8 +456,8 @@ function get_calendar($initial = true) {
else
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
} else {
- $thisyear = gmdate('Y', current_time('timestamp') + get_option('gmt_offset') * 3600);
- $thismonth = gmdate('m', current_time('timestamp') + get_option('gmt_offset') * 3600);
+ $thisyear = gmdate('Y', current_time('timestamp'));
+ $thismonth = gmdate('m', current_time('timestamp'));
}
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
@@ -758,6 +762,24 @@ function user_can_richedit() {
return apply_filters('user_can_richedit', $can);
}
+function user_can_switchedit() {
+ $can = true;
+
+ $ua = $_SERVER['HTTP_USER_AGENT'];
+
+ if (
+ !user_can_richedit() ||
+ ( // Mozilla Test
+ strstr($ua, 'Mozilla/5.0') &&
+ !strstr($ua, 'ompatible') &&
+ !strstr($ua, 'irefox')
+ )
+ )
+ $can = false;
+
+ return apply_filters('user_can_switchedit', $can);
+}
+
function the_editor($content, $id = 'content', $prev_id = 'title') {
$rows = get_option('default_post_edit_rows');
if (($rows < 3) || ($rows > 100))
@@ -768,13 +790,8 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
if ( user_can_richedit() ) :
add_filter('the_editor_content', 'wp_richedit_pre');
- // The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it.
+ if ( user_can_switchedit() ) :
?>
- <style type="text/css">
- #postdivrich table, #postdivrich #quicktags {border-top: none;}
- #quicktags {border-bottom: none; padding-bottom: 2px; margin-bottom: -1px;}
- #edButtons {border-bottom: 1px solid #ccc;}
- </style>
<div id='edButtons' style='display:none;'>
<div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div>
<input id='edButtonPreview' class='edButtonFore' type='button' value='<?php _e('Editor'); ?>' />
@@ -785,7 +802,7 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
document.getElementById('edButtons').style.display = 'block';
</script>
- <?php endif; ?>
+ <?php endif; endif; ?>
<div id="quicktags">
<?php wp_print_scripts( 'quicktags' ); ?>
<script type="text/javascript">edToolbar()</script>
@@ -820,7 +837,9 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
</script>
<?php
- $the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
+ $class = user_can_switchedit() ? 'switched' : 'unswitched';
+
+ $the_editor = apply_filters('the_editor', "<div class='$class'><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
$the_editor_content = apply_filters('the_editor_content', $content);
printf($the_editor, $the_editor_content);
diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
index c266c82..b7dadc6 100644
--- a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
+++ b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
@@ -17,6 +17,11 @@ function onLoadInit() {
document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
resizeInputs();
+
+ if (tinyMCE.getParam("theme_advanced_source_editor_wrap", true)) {
+ setWrap('soft');
+ document.forms[0].wraped.checked = true;
+ }
}
function setWrap(val) {
diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php
index 808cfb6..697100f 100644
--- a/wp-includes/js/tinymce/tiny_mce_config.php
+++ b/wp-includes/js/tinymce/tiny_mce_config.php
@@ -31,6 +31,9 @@
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'link', 'unlink', 'image', 'wp_more', 'separator', 'spellchecker', 'separator', 'wp_help', 'wp_adv_start', 'wp_adv', 'separator', 'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'wp_adv_end'));
$mce_buttons = implode($mce_buttons, ',');
+ if ( !user_can_switchedit() )
+ $mce_buttons = str_replace('wp_help', 'wp_help,code', $mce_buttons);
+
$mce_buttons_2 = apply_filters('mce_buttons_2', array());
$mce_buttons_2 = implode($mce_buttons_2, ',');
@@ -62,6 +65,7 @@ initArray = {
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
theme_advanced_resizing : true,
+ theme_advanced_source_editor_wrap : true,
browsers : "<?php echo $mce_browsers; ?>",
dialog_type : "modal",
theme_advanced_resize_horizontal : false,
diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php
index b2b099c..a29bf26 100644
--- a/wp-includes/l10n.php
+++ b/wp-includes/l10n.php
@@ -6,11 +6,15 @@ function get_locale() {
return $locale;
// WPLANG is defined in wp-config.
- if (defined('WPLANG'))
+ if ( defined('WPLANG') && '' != WPLANG )
$locale = WPLANG;
+ else if ( is_admin() )
+ $locale = get_user_lang_code();
+ else
+ $locale = get_blog_lang_code();
if (empty($locale))
- $locale = 'en_US';
+ $locale = 'en';
$locale = apply_filters('locale', $locale);
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index afd5c59..57ae28a 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -227,6 +227,8 @@ function auth_redirect() {
(empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers();
+ wp_clearcookie();
+
wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
exit();
}
diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
index cac0897..7c58519 100644
--- a/wp-includes/plugin.php
+++ b/wp-includes/plugin.php
@@ -100,7 +100,8 @@ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
}
function do_action($tag, $arg = '') {
- global $wp_filter;
+ global $wp_filter, $wp_actions;
+
$args = array();
if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this)
$args[] =& $arg[0];
@@ -132,10 +133,27 @@ function do_action($tag, $arg = '') {
}
}
}
+
+ if ( is_array($wp_actions) )
+ $wp_actions[] = $tag;
+ else
+ $wp_actions = array($tag);
+}
+
+// Returns the number of times an action has been done
+function did_action($tag) {
+ global $wp_actions;
+
+ return count(array_keys($wp_actions, $tag));
}
function do_action_ref_array($tag, $args) {
- global $wp_filter;
+ global $wp_filter, $wp_actions;
+
+ if ( !is_array($wp_actions) )
+ $wp_actions = array($tag);
+ else
+ $wp_actions[] = $tag;
merge_filters($tag);
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 7f84916..32006b8 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -349,6 +349,8 @@ function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) {
$file = get_post_meta($post->ID, '_wp_attached_file', true);
+ $exts = array('jpg', 'gif', 'png');
+
if ( !$fullsize && !empty($imagedata['thumb'])
&& ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file))
&& file_exists($thumbfile) ) {
@@ -359,7 +361,7 @@ function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) {
$src_file = $thumbfile;
$class = 'attachmentthumb';
- } elseif ( substr($mime, 0, 6) == 'image/'
+ } elseif ( ( substr($mime, 0, 6) == 'image/' || 'import' == $mime && in_array(substr($file, -3), $exts) )
&& file_exists($file) ) {
// We have an image without a thumbnail
@@ -374,7 +376,6 @@ function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) {
$icon_dir_uri = apply_filters('icon_dir_uri', get_template_directory_uri().'/images');
$types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime));
- $exts = array('jpg', 'gif', 'png');
foreach ($types as $type) {
foreach ($exts as $ext) {
$src_file = "$icon_dir/$type.$ext";
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 1968714..04f104e 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -9,7 +9,7 @@ function get_attached_file($attachment_id) {
}
function &get_children($post = 0, $output = OBJECT) {
- global $post_cache, $wpdb;
+ global $post_cache, $wpdb, $blog_id;
if ( empty($post) ) {
if ( isset($GLOBALS['post']) )
@@ -30,7 +30,7 @@ function &get_children($post = 0, $output = OBJECT) {
if ( $children ) {
foreach ( $children as $key => $child ) {
- $post_cache[$child->ID] =& $children[$key];
+ $post_cache[$blog_id][$child->ID] =& $children[$key];
$kids[$child->ID] =& $children[$key];
}
} else {
@@ -72,7 +72,7 @@ function get_extended($post) {
// Retrieves post data given a post ID or post object.
// Handles post caching.
function &get_post(&$post, $output = OBJECT) {
- global $post_cache, $wpdb;
+ global $post_cache, $wpdb, $blog_id;
if ( empty($post) ) {
if ( isset($GLOBALS['post']) )
@@ -82,25 +82,25 @@ function &get_post(&$post, $output = OBJECT) {
} elseif ( is_object($post) ) {
if ( 'page' == $post->post_type )
return get_page($post, $output);
- if ( !isset($post_cache[$post->ID]) )
- $post_cache[$post->ID] = &$post;
- $_post = & $post_cache[$post->ID];
+ if ( !isset($post_cache[$blog_id][$post->ID]) )
+ $post_cache[$blog_id][$post->ID] = &$post;
+ $_post = & $post_cache[$blog_id][$post->ID];
} else {
if ( $_post = wp_cache_get($post, 'pages') )
return get_page($_post, $output);
- elseif ( isset($post_cache[$post]) )
- $_post = & $post_cache[$post];
+ elseif ( isset($post_cache[$blog_id][$post]) )
+ $_post = & $post_cache[$blog_id][$post];
else {
$query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1";
$_post = & $wpdb->get_row($query);
if ( 'page' == $_post->post_type )
return get_page($_post, $output);
- $post_cache[$post] = & $_post;
+ $post_cache[$blog_id][$post] = & $_post;
}
}
if ( defined('WP_IMPORTING') )
- unset($post_cache);
+ unset($post_cache[$blog_id]);
if ( $output == OBJECT ) {
return $_post;
@@ -219,7 +219,7 @@ function get_posts($args) {
//
function add_post_meta($post_id, $key, $value, $unique = false) {
- global $wpdb, $post_meta_cache;
+ global $wpdb, $post_meta_cache, $blog_id;
if ( $unique ) {
if ( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
@@ -234,13 +234,13 @@ function add_post_meta($post_id, $key, $value, $unique = false) {
$wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$post_id','$key','$value')");
- $post_meta_cache['$post_id'][$key][] = $original;
+ $post_meta_cache[$blog_id]['$post_id'][$key][] = $original;
return true;
}
function delete_post_meta($post_id, $key, $value = '') {
- global $wpdb, $post_meta_cache;
+ global $wpdb, $post_meta_cache, $blog_id;
if ( empty($value) ) {
$meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
@@ -256,29 +256,29 @@ post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'");
if ( empty($value) ) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
AND meta_key = '$key'");
- unset($post_meta_cache['$post_id'][$key]);
+ unset($post_meta_cache[$blog_id]['$post_id'][$key]);
} else {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
AND meta_key = '$key' AND meta_value = '$value'");
- $cache_key = $post_meta_cache['$post_id'][$key];
+ $cache_key = $post_meta_cache[$blog_id]['$post_id'][$key];
if ($cache_key) foreach ( $cache_key as $index => $data )
if ( $data == $value )
- unset($post_meta_cache['$post_id'][$key][$index]);
+ unset($post_meta_cache[$blog_id]['$post_id'][$key][$index]);
}
- unset($post_meta_cache['$post_id'][$key]);
+ unset($post_meta_cache[$blog_id]['$post_id'][$key]);
return true;
}
function get_post_meta($post_id, $key, $single = false) {
- global $wpdb, $post_meta_cache;
+ global $wpdb, $post_meta_cache, $blog_id;
- if ( isset($post_meta_cache[$post_id][$key]) ) {
+ if ( isset($post_meta_cache[$blog_id][$post_id][$key]) ) {
if ( $single ) {
- return maybe_unserialize( $post_meta_cache[$post_id][$key][0] );
+ return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key][0] );
} else {
- return maybe_unserialize( $post_meta_cache[$post_id][$key] );
+ return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key] );
}
}
@@ -305,7 +305,7 @@ function get_post_meta($post_id, $key, $single = false) {
}
function update_post_meta($post_id, $key, $value, $prev_value = '') {
- global $wpdb, $post_meta_cache;
+ global $wpdb, $post_meta_cache, $blog_id;
$original_value = $value;
if ( is_array($value) || is_object($value) )
@@ -323,18 +323,18 @@ function update_post_meta($post_id, $key, $value, $prev_value = '') {
if ( empty($prev_value) ) {
$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
meta_key = '$key' AND post_id = '$post_id'");
- $cache_key = $post_meta_cache['$post_id'][$key];
+ $cache_key = $post_meta_cache[$blog_id]['$post_id'][$key];
if ( !empty($cache_key) )
foreach ($cache_key as $index => $data)
- $post_meta_cache['$post_id'][$key][$index] = $original_value;
+ $post_meta_cache[$blog_id]['$post_id'][$key][$index] = $original_value;
} else {
$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
- $cache_key = $post_meta_cache['$post_id'][$key];
+ $cache_key = $post_meta_cache[$blog_id]['$post_id'][$key];
if ( !empty($cache_key) )
foreach ($cache_key as $index => $data)
if ( $data == $original_prev )
- $post_meta_cache['$post_id'][$key][$index] = $original_value;
+ $post_meta_cache[$blog_id]['$post_id'][$key][$index] = $original_value;
}
return true;
@@ -342,13 +342,13 @@ meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
function get_post_custom( $post_id = 0 ) {
- global $id, $post_meta_cache, $wpdb;
+ global $id, $post_meta_cache, $wpdb, $blog_id;
if ( ! $post_id )
$post_id = $id;
- if ( isset($post_meta_cache[$post_id]) )
- return $post_meta_cache[$post_id];
+ if ( isset($post_meta_cache[$blog_id][$post_id]) )
+ return $post_meta_cache[$blog_id][$post_id];
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' ORDER BY post_id, meta_key", ARRAY_A) ) {
// Change from flat structure to hierarchical:
@@ -359,16 +359,16 @@ function get_post_custom( $post_id = 0 ) {
$mval = $metarow['meta_value'];
// Force subkeys to be array type:
- if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) )
- $post_meta_cache[$mpid] = array();
+ if ( !isset($post_meta_cache[$blog_id][$mpid]) || !is_array($post_meta_cache[$blog_id][$mpid]) )
+ $post_meta_cache[$blog_id][$mpid] = array();
- if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) )
- $post_meta_cache[$mpid]["$mkey"] = array();
+ if ( !isset($post_meta_cache[$blog_id][$mpid]["$mkey"]) || !is_array($post_meta_cache[$blog_id][$mpid]["$mkey"]) )
+ $post_meta_cache[$blog_id][$mpid]["$mkey"] = array();
// Add a value to the current pid/key:
- $post_meta_cache[$mpid][$mkey][] = $mval;
+ $post_meta_cache[$blog_id][$mpid][$mkey][] = $mval;
}
- return $post_meta_cache[$mpid];
+ return $post_meta_cache[$blog_id][$mpid];
}
}
@@ -698,7 +698,7 @@ function wp_insert_post($postarr = array()) {
// Schedule publication.
if ( 'future' == $post_status )
- wp_schedule_single_event(strtotime($post_date_gmt. ' GMT'), 'publish_future_post', $post_ID);
+ wp_schedule_single_event(strtotime($post_date_gmt. ' GMT'), 'publish_future_post', array($post_ID));
do_action('save_post', $post_ID);
do_action('wp_insert_post', $post_ID);
@@ -908,7 +908,7 @@ function get_all_page_ids() {
// Retrieves page data given a page ID or page object.
// Handles page caching.
function &get_page(&$page, $output = OBJECT) {
- global $wpdb;
+ global $wpdb, $blog_id;
if ( empty($page) ) {
if ( isset($GLOBALS['page']) ) {
@@ -926,7 +926,7 @@ function &get_page(&$page, $output = OBJECT) {
if ( isset($GLOBALS['page']->ID) && ($page == $GLOBALS['page']->ID) ) {
$_page = & $GLOBALS['page'];
wp_cache_add($_page->ID, $_page, 'pages');
- } elseif ( isset($_page) && $_page == $GLOBALS['post_cache'][$page] ) {
+ } elseif ( isset($_page) && $_page == $GLOBALS['post_cache'][$blog_id][$page] ) {
return get_post($page, $output);
} elseif ( isset($_page) && $_page == wp_cache_get($page, 'pages') ) {
// Got it.
@@ -982,10 +982,10 @@ function get_page_by_path($page_path, $output = OBJECT) {
}
function &get_page_children($page_id, $pages) {
- global $page_cache;
+ global $page_cache, $blog_id;
if ( empty($pages) )
- $pages = &$page_cache;
+ $pages = &$page_cache[$blog_id];
$page_list = array();
foreach ( $pages as $page ) {
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index cf790ab..f5585ec 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -17,7 +17,7 @@ class WP_Scripts {
$this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
$this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '09212006a' );
$mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php');
- $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '09212006' );
+ $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20061006' );
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0');
$this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4211');
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4187');
@@ -35,7 +35,7 @@ class WP_Scripts {
$this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' );
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
- $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), mt_rand() );
+ $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '4355b' );
}
}
diff --git a/wp-includes/vars.php b/wp-includes/vars.php
index 82c7b10..5bf2807 100644
--- a/wp-includes/vars.php
+++ b/wp-includes/vars.php
@@ -87,7 +87,7 @@ if (!isset($wpsmiliestrans)) {
// generates smilies' search & replace arrays
foreach($wpsmiliestrans as $smiley => $img) {
- $wp_smiliessearch[] = '/(\s|^)?'.preg_quote($smiley, '/').'(\b|\s)/';
+ $wp_smiliessearch[] = '/(\s|^|[^<])?'.preg_quote($smiley, '/').'(\b|\s|$)/';
$smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
$wp_smiliesreplace[] = " <img src='" . get_option('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
}
diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php
index cf41fee..27a158d 100644
--- a/wp-includes/wpmu-functions.php
+++ b/wp-includes/wpmu-functions.php
@@ -1,4 +1,4 @@
-<?PHP
+<?php
/*
Helper functions for WPMU
*/
@@ -163,7 +163,7 @@ function get_user_details( $username ) {
}
function get_blog_details( $id, $all = true ) {
- global $wpdb, $wpmuBaseTablePrefix;
+ global $wpdb;
$details = wp_cache_get( $id, 'blog-details' );
@@ -177,9 +177,11 @@ function get_blog_details( $id, $all = true ) {
if( $all == true ) {
$wpdb->hide_errors();
+ switch_to_blog($id);
$details->blogname = get_blog_option($id, 'blogname');
$details->siteurl = get_blog_option($id, 'siteurl');
$details->post_count = get_blog_option($id, 'post_count');
+ restore_current_blog();
$wpdb->show_errors();
wp_cache_set( $id, serialize( $details ), 'blog-details' );
@@ -288,50 +290,40 @@ function update_site_option( $key, $value ) {
}
function get_blog_option( $id, $key, $default='na' ) {
- global $wpdb, $wpmuBaseTablePrefix, $blog_id, $switched;
-
- $current_blog_id = $blog_id;
- $current_options_table = $wpdb->options;
- $wpdb->options = $wpmuBaseTablePrefix . $id . "_options";
- $blog_id = $id;
- if ($id != $current_blog_id)
- $switched = true;
+ switch_to_blog($id);
$opt = get_option( $key );
- $switched = false;
- $blog_id = $current_blog_id;
- $wpdb->options = $current_options_table;
+ restore_current_blog();
return $opt;
}
function add_blog_option( $id, $key, $value ) {
- global $wpdb, $wpmuBaseTablePrefix, $blog_id;
-
- $current_blog_id = $blog_id;
- $current_options_table = $wpdb->options;
- $wpdb->options = $wpmuBaseTablePrefix . $id . "_options";
- $blog_id = $id;
- $opt = add_option( $key, $value );
- $blog_id = $current_blog_id;
- $wpdb->options = $current_options_table;
+ switch_to_blog($id);
+ add_option( $key, $value );
+ restore_current_blog();
}
function update_blog_option( $id, $key, $value ) {
- global $wpdb, $wpmuBaseTablePrefix, $blog_id;
-
- $current_blog_id = $blog_id;
- $current_options_table = $wpdb->options;
- $wpdb->options = $wpmuBaseTablePrefix . $id . "_options";
- $blog_id = $id;
+ switch_to_blog($id);
$opt = update_option( $key, $value );
- $blog_id = $current_blog_id;
- $wpdb->options = $current_options_table;
+ restore_current_blog();
refresh_blog_details( $id );
}
function switch_to_blog( $new_blog ) {
- global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $table_prefix, $cache_settings, $category_cache, $cache_categories, $post_cache, $wp_object_cache, $blog_id, $switched, $wp_roles, $current_user;
+ global $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $current_user;
+
+ if ( empty($new_blog) )
+ $new_blog = $blog_id;
+
+ if ( empty($switched_stack) )
+ $switched_stack = array();
+
+ $switched_stack[] = $blog_id;
+
+ if ( $new_blog == $blog_id )
+ return;
// backup
$tmpoldblogdetails[ 'blogid' ] = $wpdb->blogid;
@@ -345,12 +337,7 @@ function switch_to_blog( $new_blog ) {
$tmpoldblogdetails[ 'options' ] = $wpdb->options;
$tmpoldblogdetails[ 'postmeta' ] = $wpdb->postmeta;
$tmpoldblogdetails[ 'prefix' ] = $wpdb->prefix;
- $tmpoldblogdetails[ 'cache_settings' ] = $cache_settings;
- $tmpoldblogdetails[ 'category_cache' ] = $category_cache;
- $tmpoldblogdetails[ 'cache_categories' ] = $cache_categories;
$tmpoldblogdetails[ 'table_prefix' ] = $table_prefix;
- $tmpoldblogdetails[ 'post_cache' ] = $post_cache;
- $tmpoldblogdetails[ 'wp_object_cache' ] = $wp_object_cache;
$tmpoldblogdetails[ 'blog_id' ] = $blog_id;
// fix the new prefix.
@@ -368,16 +355,6 @@ function switch_to_blog( $new_blog ) {
$wpdb->postmeta = $table_prefix . 'postmeta';
$blog_id = $new_blog;
- $cache_settings = array();
- unset( $cache_settings );
- unset( $category_cache );
- unset( $cache_categories );
- unset( $post_cache );
- //unset( $wp_object_cache );
- //$wp_object_cache = new WP_Object_Cache();
- //$wp_object_cache->cache_enabled = false;
- wp_cache_flush();
- wp_cache_close();
if( is_object( $wp_roles ) ) {
$wpdb->hide_errors();
$wp_roles->_init();
@@ -386,7 +363,6 @@ function switch_to_blog( $new_blog ) {
if ( is_object( $current_user ) ) {
$current_user->_init_caps();
}
- wp_cache_init();
do_action('switch_blog', $blog_id, $tmpoldblogdetails[ 'blog_id' ]);
@@ -394,7 +370,16 @@ function switch_to_blog( $new_blog ) {
}
function restore_current_blog() {
- global $table_prefix, $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $cache_settings, $category_cache, $cache_categories, $post_cache, $wp_object_cache, $blog_id, $switched, $wp_roles;
+ global $table_prefix, $tmpoldblogdetails, $wpdb, $wpmuBaseTablePrefix, $blog_id, $switched, $switched_stack, $wp_roles, $current_user;
+
+ if ( !$switched )
+ return;
+
+ $blog = array_pop($switched_stack);
+
+ if ( $blog_id == $blog )
+ return;
+
// backup
$wpdb->blogid = $tmpoldblogdetails[ 'blogid' ];
$wpdb->posts = $tmpoldblogdetails[ 'posts' ];
@@ -407,24 +392,19 @@ function restore_current_blog() {
$wpdb->options = $tmpoldblogdetails[ 'options' ];
$wpdb->postmeta = $tmpoldblogdetails[ 'postmeta' ];
$wpdb->prefix = $tmpoldblogdetails[ 'prefix' ];
- $cache_settings = $tmpoldblogdetails[ 'cache_settings' ];
- $category_cache = $tmpoldblogdetails[ 'category_cache' ];
- $cache_categories = $tmpoldblogdetails[ 'cache_categories' ];
$table_prefix = $tmpoldblogdetails[ 'table_prefix' ];
- $post_cache = $tmpoldblogdetails[ 'post_cache' ];
- $wp_object_cache = $tmpoldblogdetails[ 'wp_object_cache' ];
$prev_blog_id = $blog_id;
$blog_id = $tmpoldblogdetails[ 'blog_id' ];
unset( $tmpoldblogdetails );
- wp_cache_flush();
- wp_cache_close();
+
if( is_object( $wp_roles ) ) {
$wpdb->hide_errors();
$wp_roles->_init();
$wpdb->show_errors();
}
- wp_cache_init();
-
+ if ( is_object( $current_user ) ) {
+ $current_user->_init_caps();
+ }
do_action('switch_blog', $blog_id, $prev_blog_id);
$switched = false;
@@ -453,7 +433,7 @@ function get_blogs_of_user( $id ) {
if ( strstr( $key, '_capabilities') && strstr( $key, 'wp_') ) {
preg_match('/wp_(\d+)_capabilities/', $key, $match);
$blog = get_blog_details( $match[1] );
- if ( $blog && isset( $blog->domain ) ) {
+ if ( $blog && $blog->deleted == 0 && isset( $blog->domain ) ) {
$blogs[$match[1]]->userblog_id = $match[1];
$blogs[$match[1]]->domain = $blog->domain;
$blogs[$match[1]]->path = $blog->path;
@@ -614,7 +594,7 @@ function get_blog_post( $blog_id, $post_id ) {
$post = wp_cache_get( $key, "site-options" );
if( $post == false ) {
$post = $wpdb->get_row( "SELECT * FROM {$wpmuBaseTablePrefix}{$blog_id}_posts WHERE ID = '{$post_id}'" );
- wp_cache_set( $key, $post, "site-options", 30 );
+ wp_cache_set( $key, $post, "site-options", 120 );
}
return $post;
@@ -622,17 +602,7 @@ function get_blog_post( $blog_id, $post_id ) {
}
function add_user_to_blog( $blog_id, $user_id, $role ) {
- global $wpdb;
-
- $switch = false;
-
- if ( empty($blog_id) )
- $blog_id = $wpdb->blogid;
-
- if ( $blog_id != $wpdb->blogid ) {
- $switch = true;
- switch_to_blog($blog_id);
- }
+ switch_to_blog($blog_id);
$user = new WP_User($user_id);
@@ -656,21 +626,13 @@ function add_user_to_blog( $blog_id, $user_id, $role ) {
do_action('add_user_to_blog', $user_id, $role, $blog_id);
- if ( $switch )
- restore_current_blog();
+ restore_current_blog();
}
function remove_user_from_blog($user_id, $blog_id = '') {
global $wpdb;
- if ( empty($blog_id) )
- $blog_id = $wpdb->blogid;
-
- $blog_id = (int) $blog_id;
- if ( $blog_id != $wpdb->blogid ) {
- $switch = true;
- switch_to_blog($blog_id);
- }
+ switch_to_blog($blog_id);
$user_id = (int) $user_id;
@@ -704,8 +666,7 @@ function remove_user_from_blog($user_id, $blog_id = '') {
update_usermeta($user_id, 'source_domain', '');
}
- if ( $switch )
- restore_current_blog();
+ restore_current_blog();
}
function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
@@ -823,7 +784,7 @@ function validate_email( $email, $check_domain = true) {
}
function wpmu_validate_user_signup($user_name, $user_email) {
- global $wpdb;
+ global $wpdb, $current_site;
$errors = new WP_Error();
@@ -1070,8 +1031,9 @@ function wpmu_activate_signup($key) {
return new WP_Error('invalid_key', __('Invalid activation key.'));
if ( $signup->active )
- return new WP_Error('already_active', __('The blog is already active.'));
+ return new WP_Error('already_active', __('The blog is already active.'), $signup);
+ $meta = unserialize($signup->meta);
$user_login = $wpdb->escape($signup->user_login);
$user_email = $wpdb->escape($signup->user_email);
$password = generate_random_password();
@@ -1080,25 +1042,37 @@ function wpmu_activate_signup($key) {
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'));
+ return new WP_Error('create_user', __('Could not create user'), $signup);
$now = current_time('mysql', true);
if ( empty($signup->domain) ) {
$wpdb->query("UPDATE $wpdb->signups SET active = '1', activated = '$now' WHERE 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);
do_action('wpmu_activate_user', $user_id, $password, $meta);
return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta);
}
- $meta = unserialize($signup->meta);
$blog_id = wpmu_create_blog($signup->domain, $signup->path, $signup->title, $user_id, $meta);
// TODO: What to do if we create a user but cannot create a blog?
- if ( is_wp_error($blog_id) )
+ 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->query("UPDATE $wpdb->signups SET active = '1', activated = '$now' WHERE activation_key = '$key'");
+ error_log("Blog $blog_id failed to complete activation.", 0);
+ }
+
return $blog_id;
+ }
$wpdb->query("UPDATE $wpdb->signups SET active = '1', activated = '$now' WHERE activation_key = '$key'");
@@ -1123,7 +1097,6 @@ function wpmu_create_user( $user_name, $password, $email) {
if ( email_exists($email) )
return false;
-
$user_id = wp_create_user( $user_name, $password, $email );
$user = new WP_User($user_id);
// Newly created users have no roles or caps until they are added to a blog.