summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wp-admin/admin-db.php17
-rw-r--r--wp-admin/admin-footer.php2
-rw-r--r--wp-admin/admin-functions.php37
-rw-r--r--wp-admin/categories.php1
-rw-r--r--wp-admin/comment.php10
-rw-r--r--wp-admin/edit-comments.php2
-rw-r--r--wp-admin/edit-form-advanced.php31
-rw-r--r--wp-admin/edit-form-comment.php10
-rw-r--r--wp-admin/edit-form.php8
-rw-r--r--wp-admin/edit-link-form.php514
-rw-r--r--wp-admin/edit-page-form.php15
-rw-r--r--wp-admin/edit-pages.php6
-rw-r--r--wp-admin/edit.php4
-rw-r--r--wp-admin/export.php456
-rw-r--r--wp-admin/import/livejournal.php2
-rw-r--r--wp-admin/import/textpattern.php6
-rw-r--r--wp-admin/import/wordpress.php782
-rw-r--r--wp-admin/index.php8
-rw-r--r--wp-admin/link-manager.php13
-rw-r--r--wp-admin/moderation.php8
-rw-r--r--wp-admin/options-reading.php10
-rw-r--r--wp-admin/plugins.php5
-rw-r--r--wp-admin/post-new.php4
-rw-r--r--wp-admin/upgrade-functions.php4
-rw-r--r--wp-admin/user-edit.php2
-rw-r--r--wp-admin/users.php2
-rw-r--r--wp-admin/widgets.php8
-rw-r--r--wp-admin/wp-admin.css19
-rw-r--r--wp-config-sample.php2
-rw-r--r--wp-content/themes/classic/style.css20
-rw-r--r--wp-content/themes/default/archive.php17
-rw-r--r--wp-content/themes/default/functions.php832
-rw-r--r--wp-content/themes/default/sidebar.php8
-rw-r--r--wp-includes/author-template.php17
-rw-r--r--wp-includes/bookmark-template.php78
-rw-r--r--wp-includes/bookmark.php21
-rw-r--r--wp-includes/cache.php916
-rw-r--r--wp-includes/category-template.php69
-rw-r--r--wp-includes/category.php51
-rw-r--r--wp-includes/class-phpmailer.php2
-rw-r--r--wp-includes/class-snoopy.php2
-rw-r--r--wp-includes/classes.php20
-rw-r--r--wp-includes/comment-template.php4
-rw-r--r--wp-includes/comment.php49
-rw-r--r--wp-includes/compat.php2
-rw-r--r--wp-includes/deprecated.php1027
-rw-r--r--wp-includes/feed-atom-comments.php2
-rw-r--r--wp-includes/feed.php8
-rw-r--r--wp-includes/formatting.php9
-rw-r--r--wp-includes/functions.php66
-rw-r--r--wp-includes/general-template.php81
-rw-r--r--wp-includes/js/prototype.js1440
-rw-r--r--wp-includes/js/scriptaculous/builder.js17
-rw-r--r--wp-includes/js/scriptaculous/controls.js78
-rw-r--r--wp-includes/js/scriptaculous/dragdrop.js43
-rw-r--r--wp-includes/js/scriptaculous/effects.js126
-rw-r--r--wp-includes/js/scriptaculous/scriptaculous.js21
-rw-r--r--wp-includes/js/scriptaculous/slider.js7
-rw-r--r--wp-includes/js/scriptaculous/sound.js60
-rw-r--r--wp-includes/js/scriptaculous/unittest.js8
-rw-r--r--wp-includes/js/tinymce/plugins/wordpress/langs/en.js5
-rw-r--r--wp-includes/js/tinymce/tiny_mce_config.php2
-rw-r--r--wp-includes/js/tinymce/tiny_mce_popup.js2
-rw-r--r--wp-includes/kses.php190
-rw-r--r--wp-includes/link-template.php181
-rw-r--r--wp-includes/locale.php12
-rw-r--r--wp-includes/pluggable.php8
-rw-r--r--wp-includes/plugin.php12
-rw-r--r--wp-includes/post-template.php63
-rw-r--r--wp-includes/post.php91
-rw-r--r--wp-includes/registration.php2
-rw-r--r--wp-includes/rewrite.php1809
-rw-r--r--wp-includes/rss.php5
-rw-r--r--wp-includes/script-loader.php30
-rw-r--r--wp-includes/theme.php45
-rw-r--r--wp-includes/user.php2
-rw-r--r--wp-includes/vars.php46
-rw-r--r--wp-includes/widgets.php24
-rw-r--r--wp-settings.php2
-rw-r--r--xmlrpc.php202
80 files changed, 4357 insertions, 5465 deletions
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
index 5367297..6d18c96 100644
--- a/wp-admin/admin-db.php
+++ b/wp-admin/admin-db.php
@@ -83,7 +83,7 @@ function get_nonauthor_user_ids() {
function wp_insert_category($catarr) {
global $wpdb;
- extract($catarr);
+ extract($catarr, EXTR_SKIP);
if( trim( $cat_name ) == '' )
return 0;
@@ -125,11 +125,6 @@ function wp_insert_category($catarr) {
else
$links_private = 0;
-
- // Let's check if we have this category already, if so just do an update
- if ( !$update && $cat_ID = category_object_exists( $category_nicename ) )
- $update = true;
-
if (!$update) {
$maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" );
$cat_ID = mt_rand( $maxcat+100, $maxcat+4000 );
@@ -255,14 +250,6 @@ function wp_create_categories($categories, $post_id = '') {
return $cat_ids;
}
-function category_object_exists($cat_name) {
- global $wpdb;
- if (!$category_nicename = sanitize_title($cat_name))
- return 0;
-
- return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
-}
-
function category_exists($cat_name) {
global $wpdb;
if (!$category_nicename = sanitize_title($cat_name))
@@ -314,7 +301,7 @@ function wp_revoke_user($id) {
function wp_insert_link($linkdata) {
global $wpdb, $current_user;
- extract($linkdata);
+ extract($linkdata, EXTR_SKIP);
$update = false;
diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php
index 40a3e8c..8e30631 100644
--- a/wp-admin/admin-footer.php
+++ b/wp-admin/admin-footer.php
@@ -2,7 +2,7 @@
<div id="footer">
<p class="logo"><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
<p class="docs"><?php _e('<a href="http://codex.wordpress.org/">Documentation</a>'); ?> &#8212; <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br />
-<?php printf( __('Version %s'), get_bloginfo('version') ); ?></p>
+<?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p>
</div>
<?php do_action('admin_footer', ''); ?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 592c242..dce1350 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -347,6 +347,8 @@ function get_post_to_edit( $id ) {
$post->post_title = apply_filters( 'title_edit_pre', $post->post_title );
$post->post_password = format_to_edit( $post->post_password );
+
+ $post->menu_order = (int) $post->menu_order;
if ( $post->post_type == 'page' )
$post->page_template = get_post_meta( $id, '_wp_page_template', true );
@@ -396,12 +398,16 @@ function get_default_post_to_edit() {
function get_comment_to_edit( $id ) {
$comment = get_comment( $id );
+
+ $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, user_can_richedit() );
+ $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 = clean_url($comment->comment_author_url);
$comment->comment_author_url = format_to_edit( $comment->comment_author_url );
return $comment;
@@ -409,6 +415,9 @@ function get_comment_to_edit( $id ) {
function get_category_to_edit( $id ) {
$category = get_category( $id );
+
+ $category->term_id = (int) $category->term_id;
+ $category->parent = (int) $category->parent;
return $category;
}
@@ -819,8 +828,8 @@ function _cat_row( $category, $level, $name_override = false ) {
$class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
- $category->category_count = number_format_i18n( $category->category_count );
- $category->link_count = number_format_i18n( $category->link_count );
+ $category->category_count = number_format( $category->category_count );
+ $category->link_count = number_format( $category->link_count );
$posts_count = ( $category->category_count > 0 ) ? "<a href='edit.php?cat=$category->cat_ID'>$category->category_count</a>" : $category->category_count;
return "<tr id='cat-$category->cat_ID'$class>
<th scope='row' style='text-align: center'>$category->cat_ID</th>
@@ -948,7 +957,7 @@ function _wp_comment_list_item( $id, $alt = 0 ) {
<?php
if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
- echo ' | <a href="' . wp_nonce_url('ocomment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
+ echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
@@ -1039,6 +1048,7 @@ function list_meta( $meta ) {
$key_js = js_escape( $entry['meta_key'] );
$entry['meta_key'] = attribute_escape($entry['meta_key']);
$entry['meta_value'] = attribute_escape($entry['meta_value']);
+ $entry['meta_id'] = (int) $entry['meta_id'];
$r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
$r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
$r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
@@ -1091,7 +1101,7 @@ function meta_form() {
<?php
foreach ( $keys as $key ) {
- $key = attribute_escape( $key);
+ $key = attribute_escape( $key );
echo "\n\t<option value='$key'>$key</option>";
}
?>
@@ -1112,6 +1122,8 @@ 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 = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) );
$metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) );
$metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) ));
@@ -1127,6 +1139,9 @@ function add_meta( $post_ID ) {
if ( $metakeyinput)
$metakey = $metakeyinput; // default
+ if ( in_array($metakey, $protected) )
+ return false;
+
$result = $wpdb->query( "
INSERT INTO $wpdb->postmeta
(post_id,meta_key,meta_value )
@@ -1146,6 +1161,12 @@ function delete_meta( $mid ) {
function update_meta( $mid, $mkey, $mvalue ) {
global $wpdb;
+
+ $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
+
+ if ( in_array($mkey, $protected) )
+ return false;
+
$mvalue = maybe_serialize( stripslashes( $mvalue ));
$mvalue = $wpdb->escape( $mvalue );
$mid = (int) $mid;
@@ -1345,7 +1366,6 @@ function get_page_templates() {
function page_template_dropdown( $default = '' ) {
$templates = get_page_templates();
- ksort( $templates );
foreach (array_keys( $templates ) as $template )
: if ( $default == $templates[$template] )
$selected = " selected='selected'";
@@ -1945,11 +1965,8 @@ function wp_handle_upload( &$file, $overrides = false ) {
extract( $wp_filetype );
- if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
+ if ( !$type || !$ext )
return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' ));
-
- if ( !$ext )
- $ext = strrchr($file['name'], '.');
}
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
diff --git a/wp-admin/categories.php b/wp-admin/categories.php
index 40bdbf9..5e77e0f 100644
--- a/wp-admin/categories.php
+++ b/wp-admin/categories.php
@@ -118,7 +118,6 @@ cat_rows();
</div>
<?php include('edit-category-form.php'); ?>
-
<?php endif; ?>
<?php
diff --git a/wp-admin/comment.php b/wp-admin/comment.php
index 6c0872d..4390571 100644
--- a/wp-admin/comment.php
+++ b/wp-admin/comment.php
@@ -39,7 +39,7 @@ case 'mac':
$nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_';
$nonce_action .= $comment;
- if ( ! $comment = get_comment($comment) )
+ if ( ! $comment = get_comment_to_edit($comment) )
wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
@@ -91,12 +91,12 @@ case 'mac':
<?php if ( $comment->comment_author_url ) { ?>
<tr>
<th scope="row"><?php _e('URL:'); ?></th>
-<td><?php echo "<a href='$comment->comment_author_url'>$comment->comment_author_url</a>"; ?></td>
+<td><?php echo $comment->comment_author_url; ?></td>
</tr>
<?php } ?>
<tr>
<th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th>
-<td><?php echo apply_filters( 'comment_text', $comment->comment_content ); ?></td>
+<td><?php echo $comment->comment_content; ?></td>
</tr>
</table>
@@ -155,7 +155,7 @@ case 'unapprovecomment':
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
- wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$comment->comment_post_ID.'&c=1#comments');
+ wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. (int) $comment->comment_post_ID.'&c=1#comments');
}
exit();
break;
@@ -185,7 +185,7 @@ case 'approvecomment':
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
- wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$comment->comment_post_ID.'&c=1#comments');
+ wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. (int) $comment->comment_post_ID.'&c=1#comments');
}
exit();
break;
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index 7da6129..85b2a6e 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -157,7 +157,7 @@ if ( $extra_comments ) : ?>
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
?>
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
- <td style="text-align: center"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
+ <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
<td><?php comment_author_link() ?></td>
<td><?php comment_author_email_link() ?></td>
<td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index b934ed8..81a998b 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -1,10 +1,12 @@
<?php
+if ( isset($_GET['message']) )
+ $_GET['message'] = (int) $_GET['message'];
$messages[1] = __('Post updated');
$messages[2] = __('Custom field updated');
$messages[3] = __('Custom field deleted.');
?>
<?php if (isset($_GET['message'])) : ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<div id="message" class="updated fade"><p><?php echo wp_specialchars($messages[$_GET['message']]); ?></p></div>
<?php endif; ?>
<form name="post" action="post.php" method="post" id="post">
@@ -21,16 +23,17 @@ if (0 == $post_ID) {
$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
wp_nonce_field('add-post');
} else {
+ $post_ID = (int) $post_ID;
$form_action = 'editpost';
$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
wp_nonce_field('update-post_' . $post_ID);
}
-$form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />';
+$form_pingback = '<input type="hidden" name="post_pingback" value="' . (int) get_option('default_pingback_flag') . '" id="post_pingback" />';
-$form_prevstatus = '<input type="hidden" name="prev_status" value="' . $post->post_status . '" />';
+$form_prevstatus = '<input type="hidden" name="prev_status" value="' . attribute_escape( $post->post_status ) . '" />';
-$form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $post->to_ping) .'" />';
+$form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />';
if ('' != $post->pinged) {
$pings = '<p>'. __('Already pinged:') . '</p><ul>';
@@ -41,16 +44,16 @@ if ('' != $post->pinged) {
$pings .= '</ul>';
}
-$saveasdraft = '<input name="save" type="submit" id="save" tabindex="3" value="' . __('Save and Continue Editing') . '" />';
+$saveasdraft = '<input name="save" type="submit" id="save" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />';
if (empty($post->post_status)) $post->post_status = 'draft';
?>
-<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
-<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
+<input type="hidden" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
<input type="hidden" id="post_type" name="post_type" value="post" />
<?php echo $form_extra ?>
@@ -88,12 +91,12 @@ addLoadEvent(focusit);
<fieldset id="passworddiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Post Password') ?></h3>
-<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
+<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></div>
</fieldset>
<fieldset id="slugdiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Post Slug') ?></h3>
-<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
+<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /></div>
</fieldset>
<fieldset id="poststatusdiv" class="dbx-box">
@@ -125,7 +128,7 @@ foreach ($authors as $o) :
$o = get_userdata( $o->ID );
if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
else $selected = '';
-echo "<option value='$o->ID' $selected>$o->display_name</option>";
+echo "<option value='" . (int) $o->ID . "' $selected>" . wp_specialchars( $o->display_name ) . "</option>";
endforeach;
?>
</select>
@@ -140,7 +143,7 @@ endforeach;
<fieldset id="titlediv">
<legend><?php _e('Title') ?></legend>
- <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" /></div>
</fieldset>
<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
@@ -168,7 +171,7 @@ endforeach;
if ('publish' != $post->post_status || 0 == $post_ID) {
?>
<?php if ( current_user_can('publish_posts') ) : ?>
- <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+ <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish'); ?>" />
<?php endif; ?>
<?php
}
@@ -186,11 +189,11 @@ else
<?php
if (current_user_can('upload_files')) {
- $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
+ $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
$uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
- echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+ echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>
diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php
index 3e278bc..5d6f448 100644
--- a/wp-admin/edit-form-comment.php
+++ b/wp-admin/edit-form-comment.php
@@ -2,13 +2,13 @@
$submitbutton_text = __('Edit Comment &raquo;');
$toprow_title = sprintf(__('Editing Comment # %s'), $comment->comment_ID);
$form_action = 'editedcomment';
-$form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='".$comment->comment_post_ID;
+$form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='" . $comment->comment_post_ID;
?>
<form name="post" action="comment.php" method="post" id="post">
<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
<div class="wrap">
-<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
<input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
<script type="text/javascript">
@@ -20,19 +20,19 @@ addLoadEvent(focusit);
<fieldset id="namediv">
<legend><label for="name"><?php _e('Name:') ?></label></legend>
<div>
- <input type="text" name="newcomment_author" size="25" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
+ <input type="text" name="newcomment_author" size="25" value="<?php echo attribute_escape( $comment->comment_author ); ?>" tabindex="1" id="name" />
</div>
</fieldset>
<fieldset id="emaildiv">
<legend><label for="email"><?php _e('E-mail:') ?></label></legend>
<div>
- <input type="text" name="newcomment_author_email" size="20" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
+ <input type="text" name="newcomment_author_email" size="20" value="<?php echo attribute_escape( $comment->comment_author_email ); ?>" tabindex="2" id="email" />
</div>
</fieldset>
<fieldset id="uridiv">
<legend><label for="newcomment_author_url"><?php _e('URL:') ?></label></legend>
<div>
- <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" />
+ <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo attribute_escape( $comment->comment_author_url ); ?>" tabindex="3" />
</div>
</fieldset>
diff --git a/wp-admin/edit-form.php b/wp-admin/edit-form.php
index 8ed3d54..3945e3c 100644
--- a/wp-admin/edit-form.php
+++ b/wp-admin/edit-form.php
@@ -6,7 +6,7 @@
<?php if (isset($mode) && 'bookmarklet' == $mode) : ?>
<input type="hidden" name="mode" value="bookmarklet" />
<?php endif; ?>
-<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
<input type="hidden" name="action" value='post' />
<script type="text/javascript">
@@ -21,7 +21,7 @@ addLoadEvent(focusit);
<div id="poststuff">
<fieldset id="titlediv">
<legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend>
- <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" /></div>
</fieldset>
<fieldset id="categorydiv">
@@ -49,7 +49,7 @@ edCanvas = document.getElementById('content');
//-->
</script>
-<input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" />
+<input type="hidden" name="post_pingback" value="<?php echo (int) get_option('default_pingback_flag') ?>" id="post_pingback" />
<p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Locator">URL</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Locator">URL</abbr>s with spaces.)'), 'http://wordpress.org/docs/reference/post/#trackback'); echo '<br />'; ?>
<input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
@@ -64,7 +64,7 @@ edCanvas = document.getElementById('content');
<?php if ('bookmarklet' != $mode) {
echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing &raquo;') . '" />';
} ?>
- <input name="referredby" type="hidden" id="referredby" value="<?php if ( wp_get_referer() ) echo urlencode(wp_get_referer()); ?>" />
+ <input name="referredby" type="hidden" id="referredby" value="<?php if ( $refby = wp_get_referer() ) echo urlencode($refby); ?>" />
</p>
<?php do_action('simple_edit_form', ''); ?>
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php
index 4e0eece..bd226e7 100644
--- a/wp-admin/edit-link-form.php
+++ b/wp-admin/edit-link-form.php
@@ -1,257 +1,257 @@
-<?php
-if ( ! empty($link_id) ) {
- $heading = __('Edit Link');
- $submit_text = __('Save Changes &raquo;');
- $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
- $nonce_action = 'update-bookmark_' . $link_id;
-} else {
- $heading = __('Add Link');
- $submit_text = __('Add Link &raquo;');
- $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
- $nonce_action = 'add-bookmark';
-}
-
-function xfn_check($class, $value = '', $type = 'check') {
- global $link;
-
- $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"';
- }
-}
-?>
-
-<div class="wrap">
-<h2><?php echo $heading ?></h2>
-<?php echo $form ?>
-<?php wp_nonce_field($nonce_action); ?>
-
-<div id="poststuff">
-<div id="moremeta">
-<div id="grabit" class="dbx-group">
-
-<fieldset id="categorydiv" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
-<div class="dbx-content">
-<p id="jaxcat"></p>
-<ul id="categorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
-</div>
-</fieldset>
-
-<fieldset class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Target') ?></h3>
-<div class="dbx-content">
-<label for="link_target_blank" class="selectit">
-<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
-<code>_blank</code></label>
-<label for="link_target_top" class="selectit">
-<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
-<code>_top</code></label>
-<label for="link_target_none" class="selectit">
-<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
-<?php _e('none') ?></label>
-</div>
-</fieldset>
-
-<fieldset class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
-<div class="dbx-content">
-<label for="link_visible_yes" class="selectit">
-<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
-<?php _e('Yes') ?></label>
-<label for="link_visible_no" class="selectit">
-<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
-<?php _e('No') ?></label>
-</div>
-</fieldset>
-
-</div>
-</div>
-
-<table class="editform" width="100%" cellspacing="2" cellpadding="5">
-<tr>
-<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
-<td><input type="text" name="link_name" id="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
-</tr>
-<tr>
-<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th>
-<td width="80%"><input type="text" name="link_url" id="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
-</tr>
-<tr>
-<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
-<td><input type="text" name="link_description" id="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
-</tr>
-</table>
-
-<p class="submit">
-<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
-</p>
-
-<div id="advancedstuff" class="dbx-group" >
-
-<fieldset id="xfn" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
-<div class="dbx-content">
-<table class="editform" width="100%" cellspacing="2" cellpadding="5">
- <tr>
- <th width="20%" scope="row"><?php _e('rel:') ?></th>
- <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
- <td>
- <table cellpadding="3" cellspacing="5">
- <tr>
- <th scope="row"> <?php _e('identity') ?> </th>
- <td>
- <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>
- </td>
- </tr>
- <tr>
- <th scope="row"> <?php _e('friendship') ?> </th>
- <td>
- <label for="contact">
- <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
- <label for="acquaintance">
- <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
- <label for="friend">
- <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
- <label for="friendship">
- <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
- </td>
- </tr>
- <tr>
- <th scope="row"> <?php _e('physical') ?> </th>
- <td>
- <label for="met">
- <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
- <?php _e('met') ?></label>
- </td>
- </tr>
- <tr>
- <th scope="row"> <?php _e('professional') ?> </th>
- <td>
- <label for="co-worker">
- <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
- <?php _e('co-worker') ?></label>
- <label for="colleague">
- <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
- <?php _e('colleague') ?></label>
- </td>
- </tr>
- <tr>
- <th scope="row"> <?php _e('geographical') ?> </th>
- <td>
- <label for="co-resident">
- <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
- <?php _e('co-resident') ?></label>
- <label for="neighbor">
- <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
- <?php _e('neighbor') ?></label>
- <label for="geographical">
- <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
- <?php _e('none') ?></label>
- </td>
- </tr>
- <tr>
- <th scope="row"> <?php _e('family') ?> </th>
- <td>
- <label for="child">
- <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
- <?php _e('child') ?></label>
- <label for="kin">
- <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> />
- <?php _e('kin') ?></label>
- <label for="parent">
- <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
- <?php _e('parent') ?></label>
- <label for="sibling">
- <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
- <?php _e('sibling') ?></label>
- <label for="spouse">
- <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
- <?php _e('spouse') ?></label>
- <label for="family">
- <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
- <?php _e('none') ?></label>
- </td>
- </tr>
- <tr>
- <th scope="row"> <?php _e('romantic') ?> </th>
- <td>
- <label for="muse">
- <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
- <?php _e('muse') ?></label>
- <label for="crush">
- <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
- <?php _e('crush') ?></label>
- <label for="date">
- <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
- <?php _e('date') ?></label>
- <label for="romantic">
- <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
- <?php _e('sweetheart') ?></label>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-</div>
-</fieldset>
-
-<fieldset id="advanced" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
-<div class="dbx-content">
-<table class="editform" width="100%" cellspacing="2" cellpadding="5">
- <tr>
- <th width="20%" scope="row"><?php _e('Image Address:') ?></th>
- <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('RSS Address:') ?> </th>
- <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Notes:') ?></th>
- <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Rating:') ?></th>
- <td><select name="link_rating" size="1">
- <?php
- for ($r = 0; $r < 10; $r++) {
- echo(' <option value="'.$r.'" ');
- if ($link->link_rating == $r)
- echo 'selected="selected"';
- echo('>'.$r.'</option>');
- }
- ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
- </td>
- </tr>
-</table>
-</fieldset>
-</div>
-
-<?php 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 attribute_escape($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>
-</form>
-</div>
+<?php
+if ( ! empty($link_id) ) {
+ $heading = __('Edit Link');
+ $submit_text = __('Save Changes &raquo;');
+ $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+ $nonce_action = 'update-bookmark_' . $link_id;
+} else {
+ $heading = __('Add Link');
+ $submit_text = __('Add Link &raquo;');
+ $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
+ $nonce_action = 'add-bookmark';
+}
+
+function xfn_check($class, $value = '', $type = 'check') {
+ global $link;
+
+ $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"';
+ }
+}
+?>
+
+<div class="wrap">
+<h2><?php echo $heading ?></h2>
+<?php echo $form ?>
+<?php wp_nonce_field($nonce_action); ?>
+
+<div id="poststuff">
+<div id="moremeta">
+<div id="grabit" class="dbx-group">
+
+<fieldset id="categorydiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
+<div class="dbx-content">
+<p id="jaxcat"></p>
+<ul id="categorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Target') ?></h3>
+<div class="dbx-content">
+<label for="link_target_blank" class="selectit">
+<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
+<code>_blank</code></label>
+<label for="link_target_top" class="selectit">
+<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
+<code>_top</code></label>
+<label for="link_target_none" class="selectit">
+<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
+<?php _e('none') ?></label>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
+<div class="dbx-content">
+<label for="link_visible_yes" class="selectit">
+<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
+<?php _e('Yes') ?></label>
+<label for="link_visible_no" class="selectit">
+<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
+<?php _e('No') ?></label>
+</div>
+</fieldset>
+
+</div>
+</div>
+
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
+<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
+</tr>
+<tr>
+<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th>
+<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
+</tr>
+<tr>
+<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
+<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
+</tr>
+</table>
+
+<p class="submit">
+<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
+</p>
+
+<div id="advancedstuff" class="dbx-group" >
+
+<fieldset id="xfn" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('rel:') ?></th>
+ <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
+ <td>
+ <table cellpadding="3" cellspacing="5">
+ <tr>
+ <th scope="row"> <?php _e('identity') ?> </th>
+ <td>
+ <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>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('friendship') ?> </th>
+ <td>
+ <label for="contact">
+ <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
+ <label for="acquaintance">
+ <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
+ <label for="friend">
+ <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
+ <label for="friendship">
+ <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('physical') ?> </th>
+ <td>
+ <label for="met">
+ <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
+ <?php _e('met') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('professional') ?> </th>
+ <td>
+ <label for="co-worker">
+ <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
+ <?php _e('co-worker') ?></label>
+ <label for="colleague">
+ <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
+ <?php _e('colleague') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('geographical') ?> </th>
+ <td>
+ <label for="co-resident">
+ <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
+ <?php _e('co-resident') ?></label>
+ <label for="neighbor">
+ <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
+ <?php _e('neighbor') ?></label>
+ <label for="geographical">
+ <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('family') ?> </th>
+ <td>
+ <label for="child">
+ <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
+ <?php _e('child') ?></label>
+ <label for="kin">
+ <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> />
+ <?php _e('kin') ?></label>
+ <label for="parent">
+ <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
+ <?php _e('parent') ?></label>
+ <label for="sibling">
+ <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
+ <?php _e('sibling') ?></label>
+ <label for="spouse">
+ <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
+ <?php _e('spouse') ?></label>
+ <label for="family">
+ <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('romantic') ?> </th>
+ <td>
+ <label for="muse">
+ <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
+ <?php _e('muse') ?></label>
+ <label for="crush">
+ <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
+ <?php _e('crush') ?></label>
+ <label for="date">
+ <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
+ <?php _e('date') ?></label>
+ <label for="romantic">
+ <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
+ <?php _e('sweetheart') ?></label>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</div>
+</fieldset>
+
+<fieldset id="advanced" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('Image Address:') ?></th>
+ <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('RSS Address:') ?> </th>
+ <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Notes:') ?></th>
+ <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Rating:') ?></th>
+ <td><select name="link_rating" size="1">
+ <?php
+ for ($r = 0; $r < 10; $r++) {
+ echo(' <option value="'.$r.'" ');
+ if ($link->link_rating == $r)
+ echo 'selected="selected"';
+ echo('>'.$r.'</option>');
+ }
+ ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
+ </td>
+ </tr>
+</table>
+</fieldset>
+</div>
+
+<?php 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 attribute_escape($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>
+</form>
+</div>
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index f7083fd..93a6837 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -2,17 +2,22 @@
<div class="wrap">
<h2 id="write-post"><?php _e('Write Page'); ?></h2>
<?php
+
if (0 == $post_ID) {
$form_action = 'post';
$nonce_action = 'add-page';
$temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
} else {
+ $post_ID = (int) $post_ID;
$form_action = 'editpost';
$nonce_action = 'update-page_' . $post_ID;
$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
}
+$temp_ID = (int) $temp_ID;
+$user_ID = (int) $user_ID;
+
$sendto = clean_url(stripslashes(wp_get_referer()));
if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
@@ -68,7 +73,7 @@ addLoadEvent(focusit);
<fieldset id="passworddiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Page Password') ?></h3>
-<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
+<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></div>
</fieldset>
<fieldset id="pageparent" class="dbx-box">
@@ -93,7 +98,7 @@ addLoadEvent(focusit);
<fieldset id="slugdiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Page Slug') ?></h3>
-<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
+<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /></div>
</fieldset>
<?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?>
@@ -106,6 +111,8 @@ foreach ($authors as $o) :
$o = get_userdata( $o->ID );
if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
else $selected = '';
+$o->ID = (int) $o->ID;
+$o->display_name = wp_specialchars( $o->display_name );
echo "<option value='$o->ID' $selected>$o->display_name</option>";
endforeach;
?>
@@ -126,7 +133,7 @@ endforeach;
<fieldset id="titlediv">
<legend><?php _e('Page Title') ?></legend>
- <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>
+ <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" /></div>
</fieldset>
@@ -163,7 +170,7 @@ if (current_user_can('upload_files')) {
$uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
- echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+ echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php
index 3218a1f..627a031 100644
--- a/wp-admin/edit-pages.php
+++ b/wp-admin/edit-pages.php
@@ -10,16 +10,14 @@ require_once('admin-header.php');
<h2><?php _e('Page Management'); ?></h2>
<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p>
-<form name="searchform" id="searchform" action="" method="get">
+<form name="searchform" action="" method="get">
<fieldset>
<legend><?php _e('Search Pages&hellip;') ?></legend>
- <input type="text" name="s" id="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
+ <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" />
</fieldset>
</form>
-<br style="clear:both;" />
-
<?php
wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc');
diff --git a/wp-admin/edit.php b/wp-admin/edit.php
index fcb01a1..47f5ad8 100644
--- a/wp-admin/edit.php
+++ b/wp-admin/edit.php
@@ -76,7 +76,7 @@ if ( is_month() ) {
<form name="searchform" id="searchform" action="" method="get">
<fieldset>
<legend><?php _e('Search Posts&hellip;') ?></legend>
- <input type="text" name="s" id="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
+ <input type="text" name="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" />
</fieldset>
</form>
@@ -196,7 +196,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'comments':
?>
<td style="text-align: center">
- <?php comments_number("<a href='edit.php?p=$id&amp;c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
+ <?php comments_number(__('0'), "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
</td>
<?php
break;
diff --git a/wp-admin/export.php b/wp-admin/export.php
index 51e007a..33ec633 100644
--- a/wp-admin/export.php
+++ b/wp-admin/export.php
@@ -1,228 +1,228 @@
-<?php
-require_once ('admin.php');
-$title = __('Export');
-$parent_file = 'edit.php';
-
-if ( isset( $_GET['download'] ) )
- export_wp();
-
-require_once ('admin-header.php');
-?>
-
-<div class="wrap">
-<h2><?php _e('Export'); ?></h2>
-<div class="narrow">
-<p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
-<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p>
-<p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function on another WordPress blog to import this blog.'); ?></p>
-<form action="" method="get">
-<h3><?php _e('Optional options'); ?></h3>
-
-<table>
-<tr>
-<th><?php _e('Restrict Author:'); ?></th>
-<td>
-<select name="author">
-<option value="all" selected="selected"><?php _e('All'); ?></option>
-<?php
-$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
-foreach ( $authors as $id ) {
- $o = get_userdata( $id );
- echo "<option value='$o->ID'>$o->display_name</option>";
-}
-?>
-</select>
-</td>
-</tr>
-</table>
-<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
-<input type="hidden" name="download" value="true" />
-</p>
-</form>
-<p><?php _e('If you are considering moving your blog to another host we recommend a number of <a href="http://wordpress.org/hosting/">hosting services</a>.'); ?></p>
-</div>
-</div>
-
-<?php
-
-function export_wp() {
-global $wpdb, $posts, $post;
-
-$filename = 'wordpress.' . date('Y-m-d') . '.xml';
-
-header('Content-Description: File Transfer');
-header("Content-Disposition: attachment; filename=$filename");
-header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
-
-$where = '';
-if ( isset( $_GET['author'] ) && $_GET['author'] != 'all' ) {
- $author_id = (int) $_GET['author'];
- $where = " WHERE post_author = '$author_id' ";
-}
-
-$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
-
-$categories = (array) $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (category_id = cat_id) LEFT JOIN $wpdb->posts ON (post_id <=> id) $where GROUP BY cat_id");
-
-function wxr_missing_parents($categories) {
- if ( !is_array($categories) || empty($categories) )
- return array();
-
- foreach ( $categories as $category )
- $parents[$category->cat_ID] = $category->category_parent;
-
- $parents = array_unique(array_diff($parents, array_keys($parents)));
-
- if ( $zero = array_search('0', $parents) )
- unset($parents[$zero]);
-
- return $parents;
-}
-
-while ( $parents = wxr_missing_parents($categories) ) {
- $found_parents = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories WHERE cat_ID IN (" . join(', ', $parents) . ")");
- if ( is_array($found_parents) && count($found_parents) )
- $categories = array_merge($categories, $found_parents);
- else
- break;
-}
-
-// Put them in order to be inserted with no child going before its parent
-$pass = 0;
-$passes = 1000 + count($categories);
-while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) {
- if ( $cat->category_parent == 0 || isset($cats[$cat->category_parent]) ) {
- $cats[$cat->cat_ID] = $cat;
- } else {
- $categories[] = $cat;
- }
-}
-unset($categories);
-
-function wxr_cdata($str) {
- if ( seems_utf8($str) == false )
- $str = utf8_encode($str);
-
- // $str = ent2ncr(wp_specialchars($str));
-
- $str = "<![CDATA[$str" . ( ( substr($str, -1) == ']' ) ? ' ' : '') . "]]>";
-
- return $str;
-}
-
-function wxr_cat_name($c) {
- if ( empty($c->cat_name) )
- return;
-
- echo '<wp:cat_name>' . wxr_cdata($c->cat_name) . '</wp:cat_name>';
-}
-
-function wxr_category_description($c) {
- if ( empty($c->category_description) )
- return;
-
- echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>';
-}
-
-print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
-
-?>
-
-<!--
- This is a WordPress eXtended RSS file generated by WordPress as an export of
- your blog. It contains information about your blog's posts, comments, and
- categories. You may use this file to transfer that content from one site to
- another. This file is not intended to serve as a complete backup of your
- blog.
-
- To import this information into a WordPress blog follow these steps:
-
- 1. Log into that blog as an administrator.
- 2. Go to Manage > Import in the blog's admin.
- 3. Choose "WordPress" from the list of importers.
- 4. Upload this file using the form provided on that page.
- 5. You will first be asked to map the authors in this export file to users
- on the blog. For each author, you may choose to map an existing user on
- the blog or to create a new user.
- 6. WordPress will then import each of the posts, comments, and categories
- contained in this file onto your blog.
--->
-
-<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
-<rss version="2.0"
- xmlns:content="http://purl.org/rss/1.0/modules/content/"
- xmlns:wfw="http://wellformedweb.org/CommentAPI/"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:wp="http://wordpress.org/export/1.0/"
->
-
-<channel>
- <title><?php bloginfo_rss('name'); ?></title>
- <link><?php bloginfo_rss('url') ?></link>
- <description><?php bloginfo_rss("description") ?></description>
- <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
- <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
- <language><?php echo get_option('rss_language'); ?></language>
-<?php if ( $cats ) : foreach ( $cats as $c ) : ?>
- <wp:category><wp:category_nicename><?php echo $c->category_nicename; ?></wp:category_nicename><wp:category_parent><?php echo $c->category_parent ? $cats[$c->category_parent]->cat_name : ''; ?></wp:category_parent><wp:posts_private><?php echo $c->posts_private ? '1' : '0'; ?></wp:posts_private><wp:links_private><?php echo $c->links_private ? '1' : '0'; ?></wp:links_private><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category>
-<?php endforeach; endif; ?>
- <?php do_action('rss2_head'); ?>
- <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
-<item>
-<title><?php the_title_rss() ?></title>
-<link><?php permalink_single_rss() ?></link>
-<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
-<dc:creator><?php the_author() ?></dc:creator>
-<?php the_category_rss() ?>
-
-<guid isPermaLink="false"><?php the_guid(); ?></guid>
-<description></description>
-<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
-<wp:post_id><?php echo $post->ID; ?></wp:post_id>
-<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
-<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
-<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
-<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
-<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
-<wp:status><?php echo $post->post_status; ?></wp:status>
-<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
-<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order>
-<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
-<?php
-$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
-if ( $postmeta ) {
-?>
-<?php foreach( $postmeta as $meta ) { ?>
-<wp:postmeta>
-<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
-<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
-</wp:postmeta>
-<?php } ?>
-<?php } ?>
-<?php
-$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
-if ( $comments ) { foreach ( $comments as $c ) { ?>
-<wp:comment>
-<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id>
-<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
-<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
-<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
-<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
-<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
-<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
-<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
-<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
-<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
-<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
-</wp:comment>
-<?php } } ?>
- </item>
-<?php } } ?>
-</channel>
-</rss>
-<?php
- die();
-}
-
-include ('admin-footer.php');
-?>
+<?php
+require_once ('admin.php');
+$title = __('Export');
+$parent_file = 'edit.php';
+
+if ( isset( $_GET['download'] ) )
+ export_wp();
+
+require_once ('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Export'); ?></h2>
+<div class="narrow">
+<p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
+<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p>
+<p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function on another WordPress blog to import this blog.'); ?></p>
+<form action="" method="get">
+<h3><?php _e('Optional options'); ?></h3>
+
+<table>
+<tr>
+<th><?php _e('Restrict Author:'); ?></th>
+<td>
+<select name="author">
+<option value="all" selected="selected"><?php _e('All'); ?></option>
+<?php
+$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
+foreach ( $authors as $id ) {
+ $o = get_userdata( $id );
+ echo "<option value='$o->ID'>$o->display_name</option>";
+}
+?>
+</select>
+</td>
+</tr>
+</table>
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
+<input type="hidden" name="download" value="true" />
+</p>
+</form>
+<p><?php _e('If you are considering moving your blog to another host we recommend a number of <a href="http://wordpress.org/hosting/">hosting services</a>.'); ?></p>
+</div>
+</div>
+
+<?php
+
+function export_wp() {
+global $wpdb, $posts, $post;
+
+$filename = 'wordpress.' . date('Y-m-d') . '.xml';
+
+header('Content-Description: File Transfer');
+header("Content-Disposition: attachment; filename=$filename");
+header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
+
+$where = '';
+if ( isset( $_GET['author'] ) && $_GET['author'] != 'all' ) {
+ $author_id = (int) $_GET['author'];
+ $where = " WHERE post_author = '$author_id' ";
+}
+
+$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
+
+$categories = (array) $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (category_id = cat_id) LEFT JOIN $wpdb->posts ON (post_id <=> id) $where GROUP BY cat_id");
+
+function wxr_missing_parents($categories) {
+ if ( !is_array($categories) || empty($categories) )
+ return array();
+
+ foreach ( $categories as $category )
+ $parents[$category->cat_ID] = $category->category_parent;
+
+ $parents = array_unique(array_diff($parents, array_keys($parents)));
+
+ if ( $zero = array_search('0', $parents) )
+ unset($parents[$zero]);
+
+ return $parents;
+}
+
+while ( $parents = wxr_missing_parents($categories) ) {
+ $found_parents = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories WHERE cat_ID IN (" . join(', ', $parents) . ")");
+ if ( is_array($found_parents) && count($found_parents) )
+ $categories = array_merge($categories, $found_parents);
+ else
+ break;
+}
+
+// Put them in order to be inserted with no child going before its parent
+$pass = 0;
+$passes = 1000 + count($categories);
+while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) {
+ if ( $cat->category_parent == 0 || isset($cats[$cat->category_parent]) ) {
+ $cats[$cat->cat_ID] = $cat;
+ } else {
+ $categories[] = $cat;
+ }
+}
+unset($categories);
+
+function wxr_cdata($str) {
+ if ( seems_utf8($str) == false )
+ $str = utf8_encode($str);
+
+ // $str = ent2ncr(wp_specialchars($str));
+
+ $str = "<![CDATA[$str" . ( ( substr($str, -1) == ']' ) ? ' ' : '') . "]]>";
+
+ return $str;
+}
+
+function wxr_cat_name($c) {
+ if ( empty($c->cat_name) )
+ return;
+
+ echo '<wp:cat_name>' . wxr_cdata($c->cat_name) . '</wp:cat_name>';
+}
+
+function wxr_category_description($c) {
+ if ( empty($c->category_description) )
+ return;
+
+ echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>';
+}
+
+print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
+
+?>
+
+<!--
+ This is a WordPress eXtended RSS file generated by WordPress as an export of
+ your blog. It contains information about your blog's posts, comments, and
+ categories. You may use this file to transfer that content from one site to
+ another. This file is not intended to serve as a complete backup of your
+ blog.
+
+ To import this information into a WordPress blog follow these steps:
+
+ 1. Log into that blog as an administrator.
+ 2. Go to Manage > Import in the blog's admin.
+ 3. Choose "WordPress" from the list of importers.
+ 4. Upload this file using the form provided on that page.
+ 5. You will first be asked to map the authors in this export file to users
+ on the blog. For each author, you may choose to map an existing user on
+ the blog or to create a new user.
+ 6. WordPress will then import each of the posts, comments, and categories
+ contained in this file onto your blog.
+-->
+
+<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:i'); ?>"-->
+<rss version="2.0"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:wp="http://wordpress.org/export/1.0/"
+>
+
+<channel>
+ <title><?php bloginfo_rss('name'); ?></title>
+ <link><?php bloginfo_rss('url') ?></link>
+ <description><?php bloginfo_rss("description") ?></description>
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
+ <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
+ <language><?php echo get_option('rss_language'); ?></language>
+<?php if ( $cats ) : foreach ( $cats as $c ) : ?>
+ <wp:category><wp:category_nicename><?php echo $c->category_nicename; ?></wp:category_nicename><wp:category_parent><?php echo $c->category_parent ? $cats[$c->category_parent]->cat_name : ''; ?></wp:category_parent><wp:posts_private><?php echo $c->posts_private ? '1' : '0'; ?></wp:posts_private><wp:links_private><?php echo $c->links_private ? '1' : '0'; ?></wp:links_private><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category>
+<?php endforeach; endif; ?>
+ <?php do_action('rss2_head'); ?>
+ <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+<item>
+<title><?php the_title_rss() ?></title>
+<link><?php permalink_single_rss() ?></link>
+<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
+<dc:creator><?php the_author() ?></dc:creator>
+<?php the_category_rss() ?>
+
+<guid isPermaLink="false"><?php the_guid(); ?></guid>
+<description></description>
+<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
+<wp:post_id><?php echo $post->ID; ?></wp:post_id>
+<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
+<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
+<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
+<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
+<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
+<wp:status><?php echo $post->post_status; ?></wp:status>
+<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
+<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order>
+<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
+<?php
+$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
+if ( $postmeta ) {
+?>
+<?php foreach( $postmeta as $meta ) { ?>
+<wp:postmeta>
+<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
+<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
+</wp:postmeta>
+<?php } ?>
+<?php } ?>
+<?php
+$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
+if ( $comments ) { foreach ( $comments as $c ) { ?>
+<wp:comment>
+<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id>
+<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
+<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
+<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
+<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
+<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
+<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
+<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
+<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
+<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
+<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
+</wp:comment>
+<?php } } ?>
+ </item>
+<?php } } ?>
+</channel>
+</rss>
+<?php
+ die();
+}
+
+include ('admin-footer.php');
+?>
diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php
index c3b821a..ceeafeb 100644
--- a/wp-admin/import/livejournal.php
+++ b/wp-admin/import/livejournal.php
@@ -49,7 +49,7 @@ class LJ_Import {
preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $post_date);
$post_date = strtotime($post_date[1]);
- $post_date = date('Y-m-d H:i:s', $post_date);
+ $post_date = gmdate('Y-m-d H:i:s', $post_date);
preg_match('|<event>(.*?)</event>|is', $post, $post_content);
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php
index 286d74a..2d2b145 100644
--- a/wp-admin/import/textpattern.php
+++ b/wp-admin/import/textpattern.php
@@ -559,11 +559,11 @@ class Textpattern_Import {
{
echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Textpattern, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>';
echo '<h3>'.__('Users').'</h3>';
- echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn&#8217;t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
+ echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
echo '<h3>'.__('Preserving Authors').'</h3>';
echo '<p>'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
echo '<h3>'.__('Textile').'</h3>';
- echo '<p>'.__('Also, since you&#8217;re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You&#8217;ll want it.').'</p>';
+ echo '<p>'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>';
echo '<h3>'.__('WordPress Resources').'</h3>';
echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>';
echo '<ul>';
@@ -571,7 +571,7 @@ class Textpattern_Import {
echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
echo '</ul>';
- echo '<p>'.sprintf(__('That&#8217;s it! What are you waiting for? Go <a href="%1$s">login</a>!'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
+ echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
}
function db_form()
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index fa0d194..0b1aa2a 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -1,391 +1,391 @@
-<?php
-
-class WP_Import {
-
- var $posts = array ();
- var $posts_processed = array ();
- // Array of arrays. [[0] => XML fragment, [1] => New post ID]
- var $file;
- var $id;
- var $mtnames = array ();
- var $newauthornames = array ();
- var $j = -1;
-
- function header() {
- echo '<div class="wrap">';
- echo '<h2>'.__('Import WordPress').'</h2>';
- }
-
- function footer() {
- echo '</div>';
- }
-
- function unhtmlentities($string) { // From php.net for < 4.3 compat
- $trans_tbl = get_html_translation_table(HTML_ENTITIES);
- $trans_tbl = array_flip($trans_tbl);
- return strtr($string, $trans_tbl);
- }
-
- function greet() {
- echo '<div class="narrow">';
- echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, comments, custom fields, and categories into this blog.').'</p>';
- echo '<p>'.__('Choose a WordPress WXR file to upload, then click Upload file and import.').'</p>';
- wp_import_upload_form("admin.php?import=wordpress&amp;step=1");
- echo '</div>';
- }
-
- function get_tag( $string, $tag ) {
- global $wpdb;
- preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
- $return = $wpdb->escape( trim( $return[1] ) );
- return $return;
- }
-
- function users_form($n) {
- global $wpdb, $testing;
- $users = get_users_of_blog($wpdb->blogid);
-?><select name="userselect[<?php echo $n; ?>]">
- <option value="#NONE#">- Select -</option>
- <?php
- foreach ($users as $user) {
- echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
- }
-?>
- </select>
- <?php
- }
-
- //function to check the authorname and do the mapping
- function checkauthor($author) {
- global $wpdb;
-
- $map = $_POST['userselect'];
-
- $user_id = username_exists($map[$author]); //use that key to get the value of the author's name from $newauthornames
-
- return $user_id;
- }
-
- function get_entries() {
- set_magic_quotes_runtime(0);
- $importdata = array_map('rtrim', file($this->file)); // Read the file into an array
-
- $this->posts = array();
- $this->categories = array();
- $num = 0;
- $doing_entry = false;
- foreach ($importdata as $importline) {
- if ( false !== strpos($importline, '<wp:category>') ) {
- preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
- $this->categories[] = $category[1];
- continue;
- }
- if ( false !== strpos($importline, '<item>') ) {
- $this->posts[$num] = '';
- $doing_entry = true;
- continue;
- }
- if ( false !== strpos($importline, '</item>') ) {
- $num++;
- $doing_entry = false;
- continue;
- }
- if ( $doing_entry ) {
- $this->posts[$num] .= $importline . "\n";
- }
- }
-
- foreach ($this->posts as $post) {
- $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
- if ($post_ID) {
- $this->posts_processed[$post_ID][0] = &$post;
- $this->posts_processed[$post_ID][1] = 0;
- }
- }
- }
-
- function get_wp_authors() {
- $temp = array ();
- $i = -1;
- foreach ($this->posts as $post) {
- if ('' != trim($post)) {
- ++ $i;
- $author = $this->get_tag( $post, 'dc:creator' );
- array_push($temp, "$author"); //store the extracted author names in a temporary array
- }
- }
-
- // We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
- $authors[0] = array_shift($temp);
- $y = count($temp) + 1;
- for ($x = 1; $x < $y; $x ++) {
- $next = array_shift($temp);
- if (!(in_array($next, $authors)))
- array_push($authors, "$next");
- }
-
- return $authors;
- }
-
- function get_authors_from_post() {
- $formnames = array ();
- $selectnames = array ();
-
- foreach ($_POST['user'] as $key => $line) {
- $newname = trim(stripslashes($line));
- if ($newname == '')
- $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
- array_push($formnames, "$newname");
- } // $formnames is the array with the form entered names
-
- foreach ($_POST['userselect'] as $user => $key) {
- $selected = trim(stripslashes($key));
- array_push($selectnames, "$selected");
- }
-
- $count = count($formnames);
- for ($i = 0; $i < $count; $i ++) {
- if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
- array_push($this->newauthornames, "$selectnames[$i]");
- } else {
- array_push($this->newauthornames, "$formnames[$i]");
- }
- }
- }
-
- function wp_authors_form() {
-?>
-<h2><?php _e('Assign Authors'); ?></h2>
-<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
- <?php
-
-
- $authors = $this->get_wp_authors();
- echo '<ol id="authors">';
- echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
- wp_nonce_field('import-wordpress');
- $j = -1;
- foreach ($authors as $author) {
- ++ $j;
- echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.'Map to existing: ';
- $this->users_form($j);
- echo '</li>';
- }
-
- echo '<input type="submit" value="Submit">'.'<br/>';
- echo '</form>';
- echo '</ol>';
-
- }
-
- function select_authors() {
- $file = wp_import_handle_upload();
- if ( isset($file['error']) ) {
- echo '<p>'.__('Sorry, there has been an error.').'</p>';
- echo '<p><strong>' . $file['error'] . '</strong></p>';
- return;
- }
- $this->file = $file['file'];
- $this->id = (int) $file['id'];
-
- $this->get_entries();
- $this->wp_authors_form();
- }
-
- function process_categories() {
- global $wpdb;
-
- $cat_names = (array) $wpdb->get_col("SELECT cat_name FROM $wpdb->categories");
-
- while ( $c = array_shift($this->categories) ) {
- $cat_name = trim(str_replace(array ('<![CDATA[', ']]>'), '', $this->get_tag( $c, 'wp:cat_name' )));
-
- // If the category exists we leave it alone
- if ( in_array($cat_name, $cat_names) )
- continue;
-
- $category_nicename = $this->get_tag( $c, 'wp:category_nicename' );
- $posts_private = (int) $this->get_tag( $c, 'wp:posts_private' );
- $links_private = (int) $this->get_tag( $c, 'wp:links_private' );
-
- $parent = $this->get_tag( $c, 'wp:category_parent' );
-
- if ( empty($parent) )
- $category_parent = '0';
- else
- $category_parent = category_exists($parent);
-
- $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name');
-
- $cat_ID = wp_insert_category($catarr);
- }
- }
-
- function process_posts() {
- $i = -1;
- echo '<ol>';
-
- foreach ($this->posts as $post)
- $this->process_post($post);
-
- echo '</ol>';
-
- wp_import_cleanup($this->id);
-
- echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
- }
-
- function process_post($post) {
- global $wpdb;
-
- $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
- if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already
- return 0;
-
- // There are only ever one of these
- $post_title = $this->get_tag( $post, 'title' );
- $post_date = $this->get_tag( $post, 'wp:post_date' );
- $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' );
- $comment_status = $this->get_tag( $post, 'wp:comment_status' );
- $ping_status = $this->get_tag( $post, 'wp:ping_status' );
- $post_status = $this->get_tag( $post, 'wp:status' );
- $post_name = $this->get_tag( $post, 'wp:post_name' );
- $post_parent = $this->get_tag( $post, 'wp:post_parent' );
- $menu_order = $this->get_tag( $post, 'wp:menu_order' );
- $post_type = $this->get_tag( $post, 'wp:post_type' );
- $guid = $this->get_tag( $post, 'guid' );
- $post_author = $this->get_tag( $post, 'dc:creator' );
-
- $post_content = $this->get_tag( $post, 'content:encoded' );
- $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content);
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
- $post_content = str_replace('<br>', '<br />', $post_content);
- $post_content = str_replace('<hr>', '<hr />', $post_content);
-
- preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
- $categories = $categories[1];
-
- $cat_index = 0;
- foreach ($categories as $category) {
- $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category)));
- $cat_index++;
- }
-
- if ($post_id = post_exists($post_title, '', $post_date)) {
- echo '<li>';
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
- } else {
-
- // If it has parent, process parent first.
- $post_parent = (int) $post_parent;
- if ($parent = $this->posts_processed[$post_parent]) {
- if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first.
- $post_parent = $parent[1]; // New ID of the parent;
- }
-
- echo '<li>';
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
-
- $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
-
- $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type');
- $comment_post_ID = $post_id = wp_insert_post($postdata);
-
- // Memorize old and new ID.
- if ( $post_id && $post_ID && $this->posts_processed[$post_ID] )
- $this->posts_processed[$post_ID][1] = $post_id; // New ID.
-
- // Add categories.
- if (count($categories) > 0) {
- $post_cats = array();
- foreach ($categories as $category) {
- $cat_ID = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$category'");
- if ($cat_ID == 0) {
- $cat_ID = wp_insert_category(array('cat_name' => $category));
- }
- $post_cats[] = $cat_ID;
- }
- wp_set_post_categories($post_id, $post_cats);
- }
- }
-
- // Now for comments
- preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
- $comments = $comments[1];
- $num_comments = 0;
- if ( $comments) { foreach ($comments as $comment) {
- $comment_author = $this->get_tag( $comment, 'wp:comment_author');
- $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
- $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP');
- $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url');
- $comment_date = $this->get_tag( $comment, 'wp:comment_date');
- $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt');
- $comment_content = $this->get_tag( $comment, 'wp:comment_content');
- $comment_approved = $this->get_tag( $comment, 'wp:comment_approved');
- $comment_type = $this->get_tag( $comment, 'wp:comment_type');
- $comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
-
- if ( !comment_exists($comment_author, $comment_date) ) {
- $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
- wp_insert_comment($commentdata);
- $num_comments++;
- }
- } }
-
- if ( $num_comments )
- printf(' '.__('(%s comments)'), $num_comments);
-
- // Now for post meta
- preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
- $postmeta = $postmeta[1];
- if ( $postmeta) { foreach ($postmeta as $p) {
- $key = $this->get_tag( $p, 'wp:meta_key' );
- $value = $this->get_tag( $p, 'wp:meta_value' );
- $value = stripslashes($value); // add_post_meta() will escape.
- add_post_meta( $post_id, $key, $value );
- } }
- }
-
- function import() {
- $this->id = (int) $_GET['id'];
-
- $this->file = get_attached_file($this->id);
- $this->get_authors_from_post();
- $this->get_entries();
- $this->process_categories();
- $this->process_posts();
- }
-
- function dispatch() {
- if (empty ($_GET['step']))
- $step = 0;
- else
- $step = (int) $_GET['step'];
-
- $this->header();
- switch ($step) {
- case 0 :
- $this->greet();
- break;
- case 1 :
- check_admin_referer('import-upload');
- $this->select_authors();
- break;
- case 2:
- check_admin_referer('import-wordpress');
- $this->import();
- break;
- }
- $this->footer();
- }
-
- function WP_Import() {
- // Nothing.
- }
-}
-
-$wp_import = new WP_Import();
-
-register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file'), array ($wp_import, 'dispatch'));
-
-?>
+<?php
+
+class WP_Import {
+
+ var $posts = array ();
+ var $posts_processed = array ();
+ // Array of arrays. [[0] => XML fragment, [1] => New post ID]
+ var $file;
+ var $id;
+ var $mtnames = array ();
+ var $newauthornames = array ();
+ var $j = -1;
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import WordPress').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function unhtmlentities($string) { // From php.net for < 4.3 compat
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+ }
+
+ function greet() {
+ echo '<div class="narrow">';
+ echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, comments, custom fields, and categories into this blog.').'</p>';
+ echo '<p>'.__('Choose a WordPress WXR file to upload, then click Upload file and import.').'</p>';
+ wp_import_upload_form("admin.php?import=wordpress&amp;step=1");
+ echo '</div>';
+ }
+
+ function get_tag( $string, $tag ) {
+ global $wpdb;
+ preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
+ $return = $wpdb->escape( trim( $return[1] ) );
+ return $return;
+ }
+
+ function users_form($n) {
+ global $wpdb, $testing;
+ $users = get_users_of_blog($wpdb->blogid);
+?><select name="userselect[<?php echo $n; ?>]">
+ <option value="#NONE#">- Select -</option>
+ <?php
+ foreach ($users as $user) {
+ echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
+ }
+?>
+ </select>
+ <?php
+ }
+
+ //function to check the authorname and do the mapping
+ function checkauthor($author) {
+ global $wpdb;
+
+ $map = $_POST['userselect'];
+
+ $user_id = username_exists($map[$author]); //use that key to get the value of the author's name from $newauthornames
+
+ return $user_id;
+ }
+
+ function get_entries() {
+ set_magic_quotes_runtime(0);
+ $importdata = array_map('rtrim', file($this->file)); // Read the file into an array
+
+ $this->posts = array();
+ $this->categories = array();
+ $num = 0;
+ $doing_entry = false;
+ foreach ($importdata as $importline) {
+ if ( false !== strpos($importline, '<wp:category>') ) {
+ preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
+ $this->categories[] = $category[1];
+ continue;
+ }
+ if ( false !== strpos($importline, '<item>') ) {
+ $this->posts[$num] = '';
+ $doing_entry = true;
+ continue;
+ }
+ if ( false !== strpos($importline, '</item>') ) {
+ $num++;
+ $doing_entry = false;
+ continue;
+ }
+ if ( $doing_entry ) {
+ $this->posts[$num] .= $importline . "\n";
+ }
+ }
+
+ foreach ($this->posts as $post) {
+ $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
+ if ($post_ID) {
+ $this->posts_processed[$post_ID][0] = &$post;
+ $this->posts_processed[$post_ID][1] = 0;
+ }
+ }
+ }
+
+ function get_wp_authors() {
+ $temp = array ();
+ $i = -1;
+ foreach ($this->posts as $post) {
+ if ('' != trim($post)) {
+ ++ $i;
+ $author = $this->get_tag( $post, 'dc:creator' );
+ array_push($temp, "$author"); //store the extracted author names in a temporary array
+ }
+ }
+
+ // We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
+ $authors[0] = array_shift($temp);
+ $y = count($temp) + 1;
+ for ($x = 1; $x < $y; $x ++) {
+ $next = array_shift($temp);
+ if (!(in_array($next, $authors)))
+ array_push($authors, "$next");
+ }
+
+ return $authors;
+ }
+
+ function get_authors_from_post() {
+ $formnames = array ();
+ $selectnames = array ();
+
+ foreach ($_POST['user'] as $key => $line) {
+ $newname = trim(stripslashes($line));
+ if ($newname == '')
+ $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
+ array_push($formnames, "$newname");
+ } // $formnames is the array with the form entered names
+
+ foreach ($_POST['userselect'] as $user => $key) {
+ $selected = trim(stripslashes($key));
+ array_push($selectnames, "$selected");
+ }
+
+ $count = count($formnames);
+ for ($i = 0; $i < $count; $i ++) {
+ if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
+ array_push($this->newauthornames, "$selectnames[$i]");
+ } else {
+ array_push($this->newauthornames, "$formnames[$i]");
+ }
+ }
+ }
+
+ function wp_authors_form() {
+?>
+<h2><?php _e('Assign Authors'); ?></h2>
+<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
+ <?php
+
+
+ $authors = $this->get_wp_authors();
+ echo '<ol id="authors">';
+ echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
+ wp_nonce_field('import-wordpress');
+ $j = -1;
+ foreach ($authors as $author) {
+ ++ $j;
+ echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.'Map to existing: ';
+ $this->users_form($j);
+ echo '</li>';
+ }
+
+ echo '<input type="submit" value="Submit">'.'<br/>';
+ echo '</form>';
+ echo '</ol>';
+
+ }
+
+ function select_authors() {
+ $file = wp_import_handle_upload();
+ if ( isset($file['error']) ) {
+ echo '<p>'.__('Sorry, there has been an error.').'</p>';
+ echo '<p><strong>' . $file['error'] . '</strong></p>';
+ return;
+ }
+ $this->file = $file['file'];
+ $this->id = (int) $file['id'];
+
+ $this->get_entries();
+ $this->wp_authors_form();
+ }
+
+ function process_categories() {
+ global $wpdb;
+
+ $cat_names = (array) $wpdb->get_col("SELECT cat_name FROM $wpdb->categories");
+
+ while ( $c = array_shift($this->categories) ) {
+ $cat_name = trim(str_replace(array ('<![CDATA[', ']]>'), '', $this->get_tag( $c, 'wp:cat_name' )));
+
+ // If the category exists we leave it alone
+ if ( in_array($cat_name, $cat_names) )
+ continue;
+
+ $category_nicename = $this->get_tag( $c, 'wp:category_nicename' );
+ $posts_private = (int) $this->get_tag( $c, 'wp:posts_private' );
+ $links_private = (int) $this->get_tag( $c, 'wp:links_private' );
+
+ $parent = $this->get_tag( $c, 'wp:category_parent' );
+
+ if ( empty($parent) )
+ $category_parent = '0';
+ else
+ $category_parent = category_exists($parent);
+
+ $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name');
+
+ $cat_ID = wp_insert_category($catarr);
+ }
+ }
+
+ function process_posts() {
+ $i = -1;
+ echo '<ol>';
+
+ foreach ($this->posts as $post)
+ $this->process_post($post);
+
+ echo '</ol>';
+
+ wp_import_cleanup($this->id);
+
+ echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
+ }
+
+ function process_post($post) {
+ global $wpdb;
+
+ $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
+ if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already
+ return 0;
+
+ // There are only ever one of these
+ $post_title = $this->get_tag( $post, 'title' );
+ $post_date = $this->get_tag( $post, 'wp:post_date' );
+ $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' );
+ $comment_status = $this->get_tag( $post, 'wp:comment_status' );
+ $ping_status = $this->get_tag( $post, 'wp:ping_status' );
+ $post_status = $this->get_tag( $post, 'wp:status' );
+ $post_name = $this->get_tag( $post, 'wp:post_name' );
+ $post_parent = $this->get_tag( $post, 'wp:post_parent' );
+ $menu_order = $this->get_tag( $post, 'wp:menu_order' );
+ $post_type = $this->get_tag( $post, 'wp:post_type' );
+ $guid = $this->get_tag( $post, 'guid' );
+ $post_author = $this->get_tag( $post, 'dc:creator' );
+
+ $post_content = $this->get_tag( $post, 'content:encoded' );
+ $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content);
+ $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = str_replace('<br>', '<br />', $post_content);
+ $post_content = str_replace('<hr>', '<hr />', $post_content);
+
+ preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
+ $categories = $categories[1];
+
+ $cat_index = 0;
+ foreach ($categories as $category) {
+ $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category)));
+ $cat_index++;
+ }
+
+ if ($post_id = post_exists($post_title, '', $post_date)) {
+ echo '<li>';
+ printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ } else {
+
+ // If it has parent, process parent first.
+ $post_parent = (int) $post_parent;
+ if ($parent = $this->posts_processed[$post_parent]) {
+ if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first.
+ $post_parent = $parent[1]; // New ID of the parent;
+ }
+
+ echo '<li>';
+ printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+
+ $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
+
+ $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type');
+ $comment_post_ID = $post_id = wp_insert_post($postdata);
+
+ // Memorize old and new ID.
+ if ( $post_id && $post_ID && $this->posts_processed[$post_ID] )
+ $this->posts_processed[$post_ID][1] = $post_id; // New ID.
+
+ // Add categories.
+ if (count($categories) > 0) {
+ $post_cats = array();
+ foreach ($categories as $category) {
+ $cat_ID = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$category'");
+ if ($cat_ID == 0) {
+ $cat_ID = wp_insert_category(array('cat_name' => $category));
+ }
+ $post_cats[] = $cat_ID;
+ }
+ wp_set_post_categories($post_id, $post_cats);
+ }
+ }
+
+ // Now for comments
+ preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
+ $comments = $comments[1];
+ $num_comments = 0;
+ if ( $comments) { foreach ($comments as $comment) {
+ $comment_author = $this->get_tag( $comment, 'wp:comment_author');
+ $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
+ $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP');
+ $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url');
+ $comment_date = $this->get_tag( $comment, 'wp:comment_date');
+ $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt');
+ $comment_content = $this->get_tag( $comment, 'wp:comment_content');
+ $comment_approved = $this->get_tag( $comment, 'wp:comment_approved');
+ $comment_type = $this->get_tag( $comment, 'wp:comment_type');
+ $comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
+
+ if ( !comment_exists($comment_author, $comment_date) ) {
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
+ wp_insert_comment($commentdata);
+ $num_comments++;
+ }
+ } }
+
+ if ( $num_comments )
+ printf(' '.__('(%s comments)'), $num_comments);
+
+ // Now for post meta
+ preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
+ $postmeta = $postmeta[1];
+ if ( $postmeta) { foreach ($postmeta as $p) {
+ $key = $this->get_tag( $p, 'wp:meta_key' );
+ $value = $this->get_tag( $p, 'wp:meta_value' );
+ $value = stripslashes($value); // add_post_meta() will escape.
+ add_post_meta( $post_id, $key, $value );
+ } }
+ }
+
+ function import() {
+ $this->id = (int) $_GET['id'];
+
+ $this->file = get_attached_file($this->id);
+ $this->get_authors_from_post();
+ $this->get_entries();
+ $this->process_categories();
+ $this->process_posts();
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ $this->header();
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ check_admin_referer('import-upload');
+ $this->select_authors();
+ break;
+ case 2:
+ check_admin_referer('import-wordpress');
+ $this->import();
+ break;
+ }
+ $this->footer();
+ }
+
+ function WP_Import() {
+ // Nothing.
+ }
+}
+
+$wp_import = new WP_Import();
+
+register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file'), array ($wp_import, 'dispatch'));
+
+?>
diff --git a/wp-admin/index.php b/wp-admin/index.php
index a3d3151..7e70aec 100644
--- a/wp-admin/index.php
+++ b/wp-admin/index.php
@@ -43,7 +43,7 @@ if ( $comments || $numcomments ) :
<h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">&raquo;</a></h3>
<?php if ( $numcomments ) : ?>
-<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format_i18n($numcomments) ); ?> &raquo;</a></strong></p>
+<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
<?php endif; ?>
<ul>
@@ -103,9 +103,9 @@ $numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_t
$numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
$numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
-$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format_i18n($numposts), 'edit.php');
-$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format_i18n($numcomms), 'edit-comments.php');
-$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format_i18n($numcats), 'categories.php');
+$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format($numposts), 'edit.php');
+$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format($numcomms), 'edit-comments.php');
+$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format($numcats), 'categories.php');
?>
<p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p>
diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php
index 77196bb..f602097 100644
--- a/wp-admin/link-manager.php
+++ b/wp-admin/link-manager.php
@@ -199,19 +199,6 @@ if ( $links ) {
</form>
<?php } ?>
-<?php
-if( wp_cache_get( "checked_bookmarks_table", "options" ) == false ) {
- $results = $wpdb->get_results( "SELECT link_id, category_id, count( * ) AS c FROM {$wpdb->link2cat} GROUP BY link_id, category_id" );
- if( $results != null ) {
- foreach( $results as $link ) {
- if( $link->c > 1 ) {
- $wpdb->query( "DELETE FROM {$wpdb->link2cat} WHERE link_id='{$link->link_id}' AND category_id='{$link->category_id}'" );
- $wpdb->query( "INSERT INTO {$wpdb->link2cat} VALUES ( 0, '{$link->link_id}', '{$link->category_id}' )" );
- }
- }
- }
- wp_cache_set( "checked_bookmarks_table", "1", "options" );
-} ?>
</div>
diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php
index caa37ec..e24a9a1 100644
--- a/wp-admin/moderation.php
+++ b/wp-admin/moderation.php
@@ -123,14 +123,14 @@ $i = 0;
<?php comment_text() ?>
<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [ <?php
echo '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';
-echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> "; ?> ] &#8212;
+echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> | "; ?>
<?php
$post = get_post($comment->comment_post_ID);
$post_title = wp_specialchars( $post->post_title, 'double' );
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
?>
-<a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
-<p><?php _e('Bulk action:') ?>
+<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] &#8212;
+ <?php _e('Bulk action:') ?>
<input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-approve" value="approve" /> <label for="comment-<?php echo $comment->comment_ID; ?>-approve"><?php _e('Approve') ?></label> &nbsp;
<input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-spam" value="spam" /> <label for="comment-<?php echo $comment->comment_ID; ?>-spam"><?php _e('Spam') ?></label> &nbsp;
<input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-delete" value="delete" /> <label for="comment-<?php echo $comment->comment_ID; ?>-delete"><?php _e('Delete') ?></label> &nbsp;
@@ -182,7 +182,7 @@ document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark
<noscript>
<p>
- <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked &#8220;defer.&#8221; <strong>Warning: This can&#8217;t be undone.</strong>'); ?></label>
+ <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked "defer." <strong>Warning: This can&#8217;t be undone.</strong>'); ?></label>
</p>
</noscript>
</form>
diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php
index f2d01ea..9e0e8df 100644
--- a/wp-admin/options-reading.php
+++ b/wp-admin/options-reading.php
@@ -5,16 +5,6 @@ $title = __('Reading Options');
$parent_file = 'options-general.php';
include('admin-header.php');
-
-// Sanity checks
-if ( 'page' == get_option('show_on_front') ) {
- $front_page = get_option('page_on_front');
- if ( empty($front_page) ) {
- update_option('show_on_front', 'posts');
- delete_option('page_for_posts');
- delete_option('page_on_front');
- }
-}
?>
<div class="wrap">
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php
index c4e5808..ec90396 100644
--- a/wp-admin/plugins.php
+++ b/wp-admin/plugins.php
@@ -138,7 +138,10 @@ if (empty($plugins)) {
if ( $style != '' )
$style = 'class="' . $style . '"';
- $edit = '';
+ if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
+ $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
+ else
+ $edit = '';
echo "
<tr $style>
diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php
index e2c978b..fd8a046 100644
--- a/wp-admin/post-new.php
+++ b/wp-admin/post-new.php
@@ -10,7 +10,7 @@ require_once ('./admin-header.php');
if ( ! current_user_can('edit_posts') ) { ?>
<div class="wrap">
-<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />
+<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_option('admin_email')); ?>
</p>
@@ -57,7 +57,7 @@ include('edit-form-advanced.php');
<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?>
<div id="wp-bookmarklet" class="wrap">
<h3><?php _e('WordPress Bookmarklet'); ?></h3>
-<p><?php _e('Right click on the following link and choose &#0147;Bookmark This Link...&#0148; or &#0147;Add to Favorites...&#0148; to create a posting shortcut.'); ?></p>
+<p><?php _e('Right click on the following link and choose "Add to favorites" to create a posting shortcut.'); ?></p>
<p>
<?php
diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php
index 0e8e071..d162e58 100644
--- a/wp-admin/upgrade-functions.php
+++ b/wp-admin/upgrade-functions.php
@@ -175,6 +175,8 @@ function upgrade_all() {
upgrade_110();
upgrade_130();
}
+
+ maybe_disable_automattic_widgets();
if ( $wp_current_db_version < 3308 )
upgrade_160();
@@ -184,8 +186,6 @@ function upgrade_all() {
if ( $wp_current_db_version < 4351 )
upgrade_old_slugs();
-
- maybe_disable_automattic_widgets();
$wp_rewrite->flush_rules();
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
index c025f62..e3c1a3a 100644
--- a/wp-admin/user-edit.php
+++ b/wp-admin/user-edit.php
@@ -82,7 +82,7 @@ include ('admin-header.php');
<form name="profile" id="your-profile" action="user-edit.php" method="post">
<?php wp_nonce_field('update-user_' . $user_id) ?>
<?php if ( $wp_http_referer ) : ?>
- <input type="hidden" name="wp_http_referer" value="<?php echo wp_specialchars($wp_http_referer); ?>" />
+ <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" />
<?php endif; ?>
<p>
<input type="hidden" name="from" value="profile" />
diff --git a/wp-admin/users.php b/wp-admin/users.php
index bc5cac8..154a7d7 100644
--- a/wp-admin/users.php
+++ b/wp-admin/users.php
@@ -511,7 +511,7 @@ foreach($roleclasses as $role => $roleclass) {
<?php if ( !empty($role) ) : ?>
<th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
<?php else : ?>
- <th colspan="7"><h3><em><?php _e('No role for this blog'); ?></h3></th>
+ <th colspan="7"><h3><em><?php _e('No role for this blog'); ?></em></h3></th>
<?php endif; ?>
</tr>
<tr class="thead">
diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php
index a8d469e..b6b330c 100644
--- a/wp-admin/widgets.php
+++ b/wp-admin/widgets.php
@@ -68,9 +68,11 @@ function wp_widgets_admin_head() {
$A(Draggables.drags).map(function(o) {o.startDrag(null); o.finishDrag(null);});
//for ( var n in Draggables.drags ) {
for ( n=0; n<=Draggables.drags.length; n++ ) {
- if ( Draggables.drags[n].element.id == 'lastmodule' ) {
- Draggables.drags[n].destroy();
- break;
+ if ( parseInt( n ) ) {
+ if ( Draggables.drags[n].element.id == 'lastmodule' ) {
+ Draggables.drags[n].destroy();
+ break;
+ }
}
}
resetPaletteHeight();
diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css
index 14c93a2..5fc8d55 100644
--- a/wp-admin/wp-admin.css
+++ b/wp-admin/wp-admin.css
@@ -120,6 +120,7 @@ a:visited {
}
a:hover {
+/* border-bottom: 1px solid #3a75ae;*/
color: #069;
}
@@ -131,7 +132,7 @@ body {
}
body, td {
- font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+ font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
}
fieldset {
@@ -169,10 +170,10 @@ form, label input {
}
h2 {
+ border-bottom: .5em solid #e5f3ff;
color: #333;
- font: normal 32px serif;
+ font: normal 32px/5px serif;
margin: 5px 10px;
- background: url( images/heading-bg.gif ) repeat-x bottom;
}
img, #footer a {
@@ -436,7 +437,7 @@ form#upload #post_content {
}
.wrap h2 {
- margin: 0 0 .5em;
+ margin: .4em 0 .5em;
clear: both;
}
@@ -537,7 +538,7 @@ input.disabled, textarea.disabled {
border: none;
}
-#postdiv, #titlediv, #guiddiv, #tagdiv {
+#postdiv, #titlediv, #guiddiv {
margin: 0 8px 0 0;
padding: 0;
}
@@ -557,7 +558,7 @@ input.disabled, textarea.disabled {
line-height: 140%;
}
-#titlediv input, #guiddiv input, #tagdiv input {
+#titlediv input, #guiddiv input {
margin: 0;
width: 100%;
}
@@ -911,13 +912,17 @@ input.delete:hover {
}
#zeitgeist h2, fieldset legend a {
- background: none;
+ border-bottom: none;
}
* html #zeitgeist h2 {
padding-top: 10px;
}
+#zeitgeist h2 {
+ margin-top: .4em;
+}
+
#zeitgeist h3 {
border-bottom: 1px solid #ccc;
font-size: 16px;
diff --git a/wp-config-sample.php b/wp-config-sample.php
index d64bcea..e9e8d9a 100644
--- a/wp-config-sample.php
+++ b/wp-config-sample.php
@@ -18,7 +18,7 @@ $table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-content/languages.
// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
-// to enable language support.
+// to enable German language support.
define('WPLANG', '');
// uncomment this to enable wp-content/sunrise.php support
//define( 'SUNRISE', 'on' );
diff --git a/wp-content/themes/classic/style.css b/wp-content/themes/classic/style.css
index f5436b2..e09122d 100644
--- a/wp-content/themes/classic/style.css
+++ b/wp-content/themes/classic/style.css
@@ -48,9 +48,9 @@ blockquote {
body {
background: #fff;
- border: 2px solid #565;
- border-bottom: 1px solid #565;
- border-top: 3px solid #565;
+ border: solid 2px #565;
+ border-bottom: solid 1px #565;
+ border-top: solid 3px #565;
color: #000;
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif;
margin: 0;
@@ -71,7 +71,7 @@ h2 {
}
h3 {
- border-bottom: 1px dotted #eee;
+ border-bottom: dotted 1px #eee;
font-family: "Times New Roman", Times, serif;
margin-top: 0;
}
@@ -96,7 +96,7 @@ ul.post-meta span.post-meta-key {
.credit {
background: #90a090;
- border-top: 3px double #aba;
+ border-top: double 3px #aba;
color: #fff;
font-size: 11px;
margin: 10px 0 0 0;
@@ -166,10 +166,10 @@ ul.post-meta span.post-meta-key {
#header {
background: #90a090;
- border-bottom: 3px double #aba;
- border-left: 1px solid #9a9;
- border-right: 1px solid #565;
- border-top: 1px solid #9a9;
+ border-bottom: double 3px #aba;
+ border-left: solid 1px #9a9;
+ border-right: solid 1px #565;
+ border-top: solid 1px #9a9;
font: italic normal 230% 'Times New Roman', Times, serif;
letter-spacing: 0.2em;
margin: 0;
@@ -188,7 +188,7 @@ ul.post-meta span.post-meta-key {
#menu {
background: #fff;
border-left: 1px dotted #ccc;
- border-top: 3px solid #e0e6e0;
+ border-top: solid 3px #e0e6e0;
padding: 20px 0 10px 30px;
position: absolute;
right: 2px;
diff --git a/wp-content/themes/default/archive.php b/wp-content/themes/default/archive.php
index db6db4c..1d2b1de 100644
--- a/wp-content/themes/default/archive.php
+++ b/wp-content/themes/default/archive.php
@@ -4,21 +4,26 @@
<?php if (have_posts()) : ?>
- <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
- <?php /* If this is a category archive */ if (is_category()) { ?>
+ <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
+<?php /* If this is a category archive */ if (is_category()) { ?>
<h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
- <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
+
+ <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
- <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
+
+ <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
+
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h2 class="pagetitle">Author Archive</h2>
- <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
+
+ <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h2 class="pagetitle">Blog Archives</h2>
- <?php } ?>
+
+ <?php } ?>
<div class="navigation">
diff --git a/wp-content/themes/default/functions.php b/wp-content/themes/default/functions.php
index faf85ad..1ea54fc 100644
--- a/wp-content/themes/default/functions.php
+++ b/wp-content/themes/default/functions.php
@@ -1,416 +1,416 @@
-<?php
-if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'before_widget' => '<li id="%1$s" class="widget %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>',
- ));
-
-function kubrick_head() {
- $head = "<style type='text/css'>\n<!--";
- $output = '';
- if ( kubrick_header_image() ) {
- $url = kubrick_header_image_url() ;
- $output .= "#header { background: url('$url') no-repeat bottom center; }\n";
- }
- if ( false !== ( $color = kubrick_header_color() ) ) {
- $output .= "#headerimg h1 a, #headerimg h1 a:visited, #headerimg .description { color: $color; }\n";
- }
- if ( false !== ( $display = kubrick_header_display() ) ) {
- $output .= "#headerimg { display: $display }\n";
- }
- $foot = "--></style>\n";
- if ( '' != $output )
- echo $head . $output . $foot;
-}
-
-add_action('wp_head', 'kubrick_head');
-
-function kubrick_header_image() {
- return apply_filters('kubrick_header_image', get_option('kubrick_header_image'));
-}
-
-function kubrick_upper_color() {
- if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
- parse_str(substr($url, strpos($url, '?') + 1), $q);
- return $q['upper'];
- } else
- return '69aee7';
-}
-
-function kubrick_lower_color() {
- if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
- parse_str(substr($url, strpos($url, '?') + 1), $q);
- return $q['lower'];
- } else
- return '4180b6';
-}
-
-function kubrick_header_image_url() {
- if ( $image = kubrick_header_image() )
- $url = get_template_directory_uri() . '/images/' . $image;
- else
- $url = get_template_directory_uri() . '/images/kubrickheader.jpg';
-
- return $url;
-}
-
-function kubrick_header_color() {
- return apply_filters('kubrick_header_color', get_option('kubrick_header_color'));
-}
-
-function kubrick_header_color_string() {
- $color = kubrick_header_color();
- if ( false === $color )
- return 'white';
-
- return $color;
-}
-
-function kubrick_header_display() {
- return apply_filters('kubrick_header_display', get_option('kubrick_header_display'));
-}
-
-function kubrick_header_display_string() {
- $display = kubrick_header_display();
- return $display ? $display : 'inline';
-}
-
-add_action('admin_menu', 'kubrick_add_theme_page');
-
-function kubrick_add_theme_page() {
- if ( $_GET['page'] == basename(__FILE__) ) {
- if ( 'save' == $_REQUEST['action'] ) {
- check_admin_referer('kubrick-header');
- if ( isset($_REQUEST['njform']) ) {
- if ( isset($_REQUEST['defaults']) ) {
- delete_option('kubrick_header_image');
- delete_option('kubrick_header_color');
- delete_option('kubrick_header_display');
- } else {
- if ( '' == $_REQUEST['njfontcolor'] )
- delete_option('kubrick_header_color');
- else {
- $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']);
- update_option('kubrick_header_color', $fontcolor);
- }
- if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) {
- $uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0];
- $lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0];
- update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc");
- }
-
- if ( isset($_REQUEST['toggledisplay']) ) {
- if ( false === get_option('kubrick_header_display') )
- update_option('kubrick_header_display', 'none');
- else
- delete_option('kubrick_header_display');
- }
- }
- } else {
-
- if ( isset($_REQUEST['headerimage']) ) {
- check_admin_referer('kubrick-header');
- if ( '' == $_REQUEST['headerimage'] )
- delete_option('kubrick_header_image');
- else {
- $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']);
- update_option('kubrick_header_image', $headerimage);
- }
- }
-
- if ( isset($_REQUEST['fontcolor']) ) {
- check_admin_referer('kubrick-header');
- if ( '' == $_REQUEST['fontcolor'] )
- delete_option('kubrick_header_color');
- else {
- $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']);
- update_option('kubrick_header_color', $fontcolor);
- }
- }
-
- if ( isset($_REQUEST['fontdisplay']) ) {
- check_admin_referer('kubrick-header');
- if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
- delete_option('kubrick_header_display');
- else
- update_option('kubrick_header_display', 'none');
- }
- }
- //print_r($_REQUEST);
- wp_redirect("themes.php?page=functions.php&saved=true");
- die;
- }
- add_action('admin_head', 'kubrick_theme_page_head');
- }
- add_theme_page(__('Customize Header'), __('Header Image and Color'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
-}
-
-function kubrick_theme_page_head() {
-?>
-<script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script>
-<script type='text/javascript'>
-// <![CDATA[
- function pickColor(color) {
- ColorPicker_targetInput.value = color;
- kUpdate(ColorPicker_targetInput.id);
- }
- function PopupWindow_populate(contents) {
- contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="<?php echo attribute_escape(__('Close Color Picker')); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
- this.contents = contents;
- this.populated = false;
- }
- function PopupWindow_hidePopup(magicword) {
- if ( magicword != 'prettyplease' )
- return false;
- 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;
- }
- }
- return false;
- }
- function colorSelect(t,p) {
- if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" )
- cp.hidePopup('prettyplease');
- else {
- cp.p = p;
- cp.select(t,p);
- }
- }
- function PopupWindow_setSize(width,height) {
- this.width = 162;
- this.height = 210;
- }
-
- var cp = new ColorPicker();
- function advUpdate(val, obj) {
- document.getElementById(obj).value = val;
- kUpdate(obj);
- }
- function kUpdate(oid) {
- if ( 'uppercolor' == oid || 'lowercolor' == oid ) {
- uc = document.getElementById('uppercolor').value.replace('#', '');
- lc = document.getElementById('lowercolor').value.replace('#', '');
- hi = document.getElementById('headerimage');
- hi.value = 'header-img.php?upper='+uc+'&lower='+lc;
- document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/'+hi.value+'") center no-repeat';
- document.getElementById('advuppercolor').value = '#'+uc;
- document.getElementById('advlowercolor').value = '#'+lc;
- }
- if ( 'fontcolor' == oid ) {
- document.getElementById('header').style.color = document.getElementById('fontcolor').value;
- document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value;
- }
- if ( 'fontdisplay' == oid ) {
- document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
- }
- }
- function toggleDisplay() {
- td = document.getElementById('fontdisplay');
- td.value = ( td.value == 'none' ) ? 'inline' : 'none';
- kUpdate('fontdisplay');
- }
- function toggleAdvanced() {
- a = document.getElementById('jsAdvanced');
- if ( a.style.display == 'none' )
- a.style.display = 'block';
- else
- a.style.display = 'none';
- }
- function kDefaults() {
- document.getElementById('headerimage').value = '';
- document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7';
- document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6';
- document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/kubrickheader.jpg") center no-repeat';
- document.getElementById('header').style.color = '#FFFFFF';
- document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '';
- document.getElementById('fontdisplay').value = 'inline';
- document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
- }
- function kRevert() {
- document.getElementById('headerimage').value = '<?php echo js_escape(kubrick_header_image()); ?>';
- document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo js_escape(kubrick_upper_color()); ?>';
- document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo js_escape(kubrick_lower_color()); ?>';
- document.getElementById('header').style.background = 'url("<?php echo js_escape(kubrick_header_image_url()); ?>") center no-repeat';
- document.getElementById('header').style.color = '';
- document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo js_escape(kubrick_header_color_string()); ?>';
- document.getElementById('fontdisplay').value = '<?php echo js_escape(kubrick_header_display_string()); ?>';
- document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
- }
- function kInit() {
- document.getElementById('jsForm').style.display = 'block';
- document.getElementById('nonJsForm').style.display = 'none';
- }
- addLoadEvent(kInit);
-// ]]>
-</script>
-<style type='text/css'>
- #headwrap {
- text-align: center;
- }
- #kubrick-header {
- font-size: 80%;
- }
- #kubrick-header .hibrowser {
- width: 780px;
- height: 260px;
- overflow: scroll;
- }
- #kubrick-header #hitarget {
- display: none;
- }
- #kubrick-header #header h1 {
- font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
- font-weight: bold;
- font-size: 4em;
- text-align: center;
- padding-top: 70px;
- margin: 0;
- }
-
- #kubrick-header #header .description {
- font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
- font-size: 1.2em;
- text-align: center;
- }
- #kubrick-header #header {
- text-decoration: none;
- color: <?php echo kubrick_header_color_string(); ?>;
- padding: 0;
- margin: 0;
- height: 200px;
- text-align: center;
- background: url('<?php echo kubrick_header_image_url(); ?>') center no-repeat;
- }
- #kubrick-header #headerimg {
- margin: 0;
- height: 200px;
- width: 100%;
- display: <?php echo kubrick_header_display_string(); ?>;
- }
- #jsForm {
- display: none;
- text-align: center;
- }
- #jsForm input.submit, #jsForm input.button, #jsAdvanced input.button {
- padding: 0px;
- margin: 0px;
- }
- #advanced {
- text-align: center;
- width: 620px;
- }
- html>body #advanced {
- text-align: center;
- position: relative;
- left: 50%;
- margin-left: -380px;
- }
- #jsAdvanced {
- text-align: right;
- }
- #nonJsForm {
- position: relative;
- text-align: left;
- margin-left: -370px;
- left: 50%;
- }
- #nonJsForm label {
- padding-top: 6px;
- padding-right: 5px;
- float: left;
- width: 100px;
- text-align: right;
- }
- .defbutton {
- font-weight: bold;
- }
- .zerosize {
- width: 0px;
- height: 0px;
- overflow: hidden;
- }
- #colorPickerDiv a, #colorPickerDiv a:hover {
- padding: 1px;
- text-decoration: none;
- border-bottom: 0px;
- }
-</style>
-<?php
-}
-
-function kubrick_theme_page() {
- if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>';
-?>
-<div class='wrap'>
- <div id="kubrick-header">
- <h2><?php _e('Header Image and Color'); ?></h2>
- <div id="headwrap">
- <div id="header">
- <div id="headerimg">
- <h1><?php bloginfo('name'); ?></h1>
- <div class="description"><?php bloginfo('description'); ?></div>
- </div>
- </div>
- </div>
- <br />
- <div id="nonJsForm">
- <form method="post" action="">
- <?php wp_nonce_field('kubrick-header'); ?>
- <div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php echo attribute_escape(__('Save')); ?>" /></div>
- <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br />
- <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
- <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
- <input type="hidden" name="hi" id="hi" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
- <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php echo attribute_escape(__('Toggle Text')); ?>" />
- <input type="submit" name="defaults" value="<?php echo attribute_escape(__('Use Defaults')); ?>" />
- <input type="submit" class="defbutton" name="submitform" value="&nbsp;&nbsp;<?php _e('Save'); ?>&nbsp;&nbsp;" />
- <input type="hidden" name="action" value="save" />
- <input type="hidden" name="njform" value="true" />
- </form>
- </div>
- <div id="jsForm">
- <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
- <?php wp_nonce_field('kubrick-header'); ?>
- <input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php echo attribute_escape(__('Font Color')); ?>"></input>
- <input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php echo attribute_escape(__('Upper Color')); ?>"></input>
- <input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php echo attribute_escape(__('Lower Color')); ?>"></input>
- <input type="button" name="revert" value="<?php echo attribute_escape(__('Revert')); ?>" onclick="kRevert()" />
- <input type="button" value="<?php echo attribute_escape(__('Advanced')); ?>" onclick="toggleAdvanced()" />
- <input type="hidden" name="action" value="save" />
- <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo attribute_escape(kubrick_header_display()); ?>" />
- <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" />
- <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo attribute_escape(kubrick_upper_color()); ?>" />
- <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo attribute_escape(kubrick_lower_color()); ?>" />
- <input type="hidden" name="headerimage" id="headerimage" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
- <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php echo attribute_escape(__('Update Header &raquo;')); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
- </form>
- <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
- <div id="advanced">
- <form id="jsAdvanced" style="display:none;" action="">
- <?php wp_nonce_field('kubrick-header'); ?>
- <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /><br />
- <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /><br />
- <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /><br />
- <input type="button" name="default" value="<?php echo attribute_escape(__('Select Default Colors')); ?>" onclick="kDefaults()" /><br />
- <input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php echo attribute_escape(__('Toggle Text Display')); ?>"></input><br />
- </form>
- </div>
- </div>
- </div>
-</div>
-<?php } ?>
+<?php
+if ( function_exists('register_sidebar') )
+ register_sidebar(array(
+ 'before_widget' => '<li id="%1$s" class="widget %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h2 class="widgettitle">',
+ 'after_title' => '</h2>',
+ ));
+
+function kubrick_head() {
+ $head = "<style type='text/css'>\n<!--";
+ $output = '';
+ if ( kubrick_header_image() ) {
+ $url = kubrick_header_image_url() ;
+ $output .= "#header { background: url('$url') no-repeat bottom center; }\n";
+ }
+ if ( false !== ( $color = kubrick_header_color() ) ) {
+ $output .= "#headerimg h1 a, #headerimg h1 a:visited, #headerimg .description { color: $color; }\n";
+ }
+ if ( false !== ( $display = kubrick_header_display() ) ) {
+ $output .= "#headerimg { display: $display }\n";
+ }
+ $foot = "--></style>\n";
+ if ( '' != $output )
+ echo $head . $output . $foot;
+}
+
+add_action('wp_head', 'kubrick_head');
+
+function kubrick_header_image() {
+ return apply_filters('kubrick_header_image', get_option('kubrick_header_image'));
+}
+
+function kubrick_upper_color() {
+ if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
+ parse_str(substr($url, strpos($url, '?') + 1), $q);
+ return $q['upper'];
+ } else
+ return '69aee7';
+}
+
+function kubrick_lower_color() {
+ if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
+ parse_str(substr($url, strpos($url, '?') + 1), $q);
+ return $q['lower'];
+ } else
+ return '4180b6';
+}
+
+function kubrick_header_image_url() {
+ if ( $image = kubrick_header_image() )
+ $url = get_template_directory_uri() . '/images/' . $image;
+ else
+ $url = get_template_directory_uri() . '/images/kubrickheader.jpg';
+
+ return $url;
+}
+
+function kubrick_header_color() {
+ return apply_filters('kubrick_header_color', get_option('kubrick_header_color'));
+}
+
+function kubrick_header_color_string() {
+ $color = kubrick_header_color();
+ if ( false === $color )
+ return 'white';
+
+ return $color;
+}
+
+function kubrick_header_display() {
+ return apply_filters('kubrick_header_display', get_option('kubrick_header_display'));
+}
+
+function kubrick_header_display_string() {
+ $display = kubrick_header_display();
+ return $display ? $display : 'inline';
+}
+
+add_action('admin_menu', 'kubrick_add_theme_page');
+
+function kubrick_add_theme_page() {
+ if ( $_GET['page'] == basename(__FILE__) ) {
+ if ( 'save' == $_REQUEST['action'] ) {
+ check_admin_referer('kubrick-header');
+ if ( isset($_REQUEST['njform']) ) {
+ if ( isset($_REQUEST['defaults']) ) {
+ delete_option('kubrick_header_image');
+ delete_option('kubrick_header_color');
+ delete_option('kubrick_header_display');
+ } else {
+ if ( '' == $_REQUEST['njfontcolor'] )
+ delete_option('kubrick_header_color');
+ else {
+ $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']);
+ update_option('kubrick_header_color', $fontcolor);
+ }
+ if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) {
+ $uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0];
+ $lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0];
+ update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc");
+ }
+
+ if ( isset($_REQUEST['toggledisplay']) ) {
+ if ( false === get_option('kubrick_header_display') )
+ update_option('kubrick_header_display', 'none');
+ else
+ delete_option('kubrick_header_display');
+ }
+ }
+ } else {
+
+ if ( isset($_REQUEST['headerimage']) ) {
+ check_admin_referer('kubrick-header');
+ if ( '' == $_REQUEST['headerimage'] )
+ delete_option('kubrick_header_image');
+ else {
+ $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']);
+ update_option('kubrick_header_image', $headerimage);
+ }
+ }
+
+ if ( isset($_REQUEST['fontcolor']) ) {
+ check_admin_referer('kubrick-header');
+ if ( '' == $_REQUEST['fontcolor'] )
+ delete_option('kubrick_header_color');
+ else {
+ $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']);
+ update_option('kubrick_header_color', $fontcolor);
+ }
+ }
+
+ if ( isset($_REQUEST['fontdisplay']) ) {
+ check_admin_referer('kubrick-header');
+ if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
+ delete_option('kubrick_header_display');
+ else
+ update_option('kubrick_header_display', 'none');
+ }
+ }
+ //print_r($_REQUEST);
+ wp_redirect("themes.php?page=functions.php&saved=true");
+ die;
+ }
+ add_action('admin_head', 'kubrick_theme_page_head');
+ }
+ add_theme_page(__('Customize Header'), __('Header Image and Color'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
+}
+
+function kubrick_theme_page_head() {
+?>
+<script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script>
+<script type='text/javascript'>
+// <![CDATA[
+ function pickColor(color) {
+ ColorPicker_targetInput.value = color;
+ kUpdate(ColorPicker_targetInput.id);
+ }
+ function PopupWindow_populate(contents) {
+ contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="<?php echo attribute_escape(__('Close Color Picker')); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
+ this.contents = contents;
+ this.populated = false;
+ }
+ function PopupWindow_hidePopup(magicword) {
+ if ( magicword != 'prettyplease' )
+ return false;
+ 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;
+ }
+ }
+ return false;
+ }
+ function colorSelect(t,p) {
+ if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" )
+ cp.hidePopup('prettyplease');
+ else {
+ cp.p = p;
+ cp.select(t,p);
+ }
+ }
+ function PopupWindow_setSize(width,height) {
+ this.width = 162;
+ this.height = 210;
+ }
+
+ var cp = new ColorPicker();
+ function advUpdate(val, obj) {
+ document.getElementById(obj).value = val;
+ kUpdate(obj);
+ }
+ function kUpdate(oid) {
+ if ( 'uppercolor' == oid || 'lowercolor' == oid ) {
+ uc = document.getElementById('uppercolor').value.replace('#', '');
+ lc = document.getElementById('lowercolor').value.replace('#', '');
+ hi = document.getElementById('headerimage');
+ hi.value = 'header-img.php?upper='+uc+'&lower='+lc;
+ document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/'+hi.value+'") center no-repeat';
+ document.getElementById('advuppercolor').value = '#'+uc;
+ document.getElementById('advlowercolor').value = '#'+lc;
+ }
+ if ( 'fontcolor' == oid ) {
+ document.getElementById('header').style.color = document.getElementById('fontcolor').value;
+ document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value;
+ }
+ if ( 'fontdisplay' == oid ) {
+ document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
+ }
+ }
+ function toggleDisplay() {
+ td = document.getElementById('fontdisplay');
+ td.value = ( td.value == 'none' ) ? 'inline' : 'none';
+ kUpdate('fontdisplay');
+ }
+ function toggleAdvanced() {
+ a = document.getElementById('jsAdvanced');
+ if ( a.style.display == 'none' )
+ a.style.display = 'block';
+ else
+ a.style.display = 'none';
+ }
+ function kDefaults() {
+ document.getElementById('headerimage').value = '';
+ document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7';
+ document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6';
+ document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/kubrickheader.jpg") center no-repeat';
+ document.getElementById('header').style.color = '#FFFFFF';
+ document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '';
+ document.getElementById('fontdisplay').value = 'inline';
+ document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
+ }
+ function kRevert() {
+ document.getElementById('headerimage').value = '<?php echo js_escape(kubrick_header_image()); ?>';
+ document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo js_escape(kubrick_upper_color()); ?>';
+ document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo js_escape(kubrick_lower_color()); ?>';
+ document.getElementById('header').style.background = 'url("<?php echo js_escape(kubrick_header_image_url()); ?>") center no-repeat';
+ document.getElementById('header').style.color = '';
+ document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo js_escape(kubrick_header_color_string()); ?>';
+ document.getElementById('fontdisplay').value = '<?php echo js_escape(kubrick_header_display_string()); ?>';
+ document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
+ }
+ function kInit() {
+ document.getElementById('jsForm').style.display = 'block';
+ document.getElementById('nonJsForm').style.display = 'none';
+ }
+ addLoadEvent(kInit);
+// ]]>
+</script>
+<style type='text/css'>
+ #headwrap {
+ text-align: center;
+ }
+ #kubrick-header {
+ font-size: 80%;
+ }
+ #kubrick-header .hibrowser {
+ width: 780px;
+ height: 260px;
+ overflow: scroll;
+ }
+ #kubrick-header #hitarget {
+ display: none;
+ }
+ #kubrick-header #header h1 {
+ font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
+ font-weight: bold;
+ font-size: 4em;
+ text-align: center;
+ padding-top: 70px;
+ margin: 0;
+ }
+
+ #kubrick-header #header .description {
+ font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
+ font-size: 1.2em;
+ text-align: center;
+ }
+ #kubrick-header #header {
+ text-decoration: none;
+ color: <?php echo kubrick_header_color_string(); ?>;
+ padding: 0;
+ margin: 0;
+ height: 200px;
+ text-align: center;
+ background: url('<?php echo kubrick_header_image_url(); ?>') center no-repeat;
+ }
+ #kubrick-header #headerimg {
+ margin: 0;
+ height: 200px;
+ width: 100%;
+ display: <?php echo kubrick_header_display_string(); ?>;
+ }
+ #jsForm {
+ display: none;
+ text-align: center;
+ }
+ #jsForm input.submit, #jsForm input.button, #jsAdvanced input.button {
+ padding: 0px;
+ margin: 0px;
+ }
+ #advanced {
+ text-align: center;
+ width: 620px;
+ }
+ html>body #advanced {
+ text-align: center;
+ position: relative;
+ left: 50%;
+ margin-left: -380px;
+ }
+ #jsAdvanced {
+ text-align: right;
+ }
+ #nonJsForm {
+ position: relative;
+ text-align: left;
+ margin-left: -370px;
+ left: 50%;
+ }
+ #nonJsForm label {
+ padding-top: 6px;
+ padding-right: 5px;
+ float: left;
+ width: 100px;
+ text-align: right;
+ }
+ .defbutton {
+ font-weight: bold;
+ }
+ .zerosize {
+ width: 0px;
+ height: 0px;
+ overflow: hidden;
+ }
+ #colorPickerDiv a, #colorPickerDiv a:hover {
+ padding: 1px;
+ text-decoration: none;
+ border-bottom: 0px;
+ }
+</style>
+<?php
+}
+
+function kubrick_theme_page() {
+ if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>';
+?>
+<div class='wrap'>
+ <div id="kubrick-header">
+ <h2><?php _e('Header Image and Color'); ?></h2>
+ <div id="headwrap">
+ <div id="header">
+ <div id="headerimg">
+ <h1><?php bloginfo('name'); ?></h1>
+ <div class="description"><?php bloginfo('description'); ?></div>
+ </div>
+ </div>
+ </div>
+ <br />
+ <div id="nonJsForm">
+ <form method="post" action="">
+ <?php wp_nonce_field('kubrick-header'); ?>
+ <div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php echo attribute_escape(__('Save')); ?>" /></div>
+ <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br />
+ <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
+ <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
+ <input type="hidden" name="hi" id="hi" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
+ <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php echo attribute_escape(__('Toggle Text')); ?>" />
+ <input type="submit" name="defaults" value="<?php echo attribute_escape(__('Use Defaults')); ?>" />
+ <input type="submit" class="defbutton" name="submitform" value="&nbsp;&nbsp;<?php _e('Save'); ?>&nbsp;&nbsp;" />
+ <input type="hidden" name="action" value="save" />
+ <input type="hidden" name="njform" value="true" />
+ </form>
+ </div>
+ <div id="jsForm">
+ <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo attribute_escape($_SERVER['REQUEST_URI']); ?>">
+ <?php wp_nonce_field('kubrick-header'); ?>
+ <input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php echo attribute_escape(__('Font Color')); ?>"></input>
+ <input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php echo attribute_escape(__('Upper Color')); ?>"></input>
+ <input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php echo attribute_escape(__('Lower Color')); ?>"></input>
+ <input type="button" name="revert" value="<?php echo attribute_escape(__('Revert')); ?>" onclick="kRevert()" />
+ <input type="button" value="<?php echo attribute_escape(__('Advanced')); ?>" onclick="toggleAdvanced()" />
+ <input type="hidden" name="action" value="save" />
+ <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo attribute_escape(kubrick_header_display()); ?>" />
+ <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" />
+ <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo attribute_escape(kubrick_upper_color()); ?>" />
+ <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo attribute_escape(kubrick_lower_color()); ?>" />
+ <input type="hidden" name="headerimage" id="headerimage" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
+ <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php echo attribute_escape(__('Update Header &raquo;')); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
+ </form>
+ <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
+ <div id="advanced">
+ <form id="jsAdvanced" style="display:none;" action="">
+ <?php wp_nonce_field('kubrick-header'); ?>
+ <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /><br />
+ <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /><br />
+ <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /><br />
+ <input type="button" name="default" value="<?php echo attribute_escape(__('Select Default Colors')); ?>" onclick="kDefaults()" /><br />
+ <input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php echo attribute_escape(__('Toggle Text Display')); ?>"></input><br />
+ </form>
+ </div>
+ </div>
+ </div>
+</div>
+<?php } ?>
diff --git a/wp-content/themes/default/sidebar.php b/wp-content/themes/default/sidebar.php
index 0fdccda..1cb2dea 100644
--- a/wp-content/themes/default/sidebar.php
+++ b/wp-content/themes/default/sidebar.php
@@ -2,14 +2,6 @@
<ul>
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
-<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : ?>
-
- </ul>
- </div>
-<?php return; ?>
-
-<?php endif; ?>
-
<li>
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
</li>
diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php
index 6006cf3..cc67faf 100644
--- a/wp-includes/author-template.php
+++ b/wp-includes/author-template.php
@@ -175,14 +175,15 @@ function get_author_name( $auth_id ) {
function wp_list_authors($args = '') {
global $wpdb;
- $defaults = array(
- 'optioncount' => false, 'exclude_admin' => true,
- 'show_fullname' => false, 'hide_empty' => true,
- 'feed' => '', 'feed_image' => ''
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract($r);
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true,
+ 'feed' => '', 'feed_image' => '');
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
// TODO: Move select to get_authors().
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php
index 2a06cf2..79bf8a3 100644
--- a/wp-includes/bookmark-template.php
+++ b/wp-includes/bookmark-template.php
@@ -9,23 +9,28 @@
**/
function wp_get_links($args = '') {
global $wpdb;
-
- if ( strpos( $args, '=' ) === false ) {
+
+ if ( empty($args) )
+ return;
+
+ if ( false === strpos($args, '=') ) {
$cat_id = $args;
- $args = add_query_arg( 'category', $cat_id, $args );
+ $args = add_query_arg('category', $cat_id, $args);
}
-
- $defaults = array(
- 'category' => -1, 'before' => '',
- 'after' => '<br />', 'between' => ' ',
- 'show_images' => true, 'orderby' => 'name',
- 'show_description' => true, 'show_rating' => false,
- 'limit' => -1, 'show_updated' => true,
- 'echo' => true
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+
+ parse_str($args);
+
+ if ( !isset($category) ) $category = -1;
+ if ( !isset($before) ) $before = '';
+ if ( !isset($after) ) $after = '<br />';
+ if ( !isset($between) ) $between = ' ';
+ if ( !isset($show_images) ) $show_images = true;
+ if ( !isset($orderby) ) $orderby = 'name';
+ if ( !isset($show_description) ) $show_description = true;
+ if ( !isset($show_rating) ) $show_rating = false;
+ if ( !isset($limit) ) $limit = -1;
+ if ( !isset($show_updated) ) $show_updated = 1;
+ if ( !isset($echo) ) $echo = true;
return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
} // end wp_get_links
@@ -240,14 +245,15 @@ function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
}
function _walk_bookmarks($bookmarks, $args = '' ) {
- $defaults = array(
- 'show_updated' => 0, 'show_description' => 0,
- 'show_images' => 1, 'before' => '<li>',
- 'after' => '</li>', 'between' => "\n"
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('show_updated' => 0, 'show_description' => 0, 'show_images' => 1, 'before' => '<li>',
+ 'after' => '</li>', 'between' => "\n");
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
foreach ( (array) $bookmarks as $bookmark ) {
if ( !isset($bookmark->recently_updated) )
@@ -314,20 +320,18 @@ function _walk_bookmarks($bookmarks, $args = '' ) {
}
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',
- 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
- 'category_after' => '</li>'
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $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', 'class' => 'linkcat',
+ 'category_before' => '<li id="%id" class="%class">', 'category_after' => '</li>');
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
$output = '';
diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php
index ad2e696..aca1e72 100644
--- a/wp-includes/bookmark.php
+++ b/wp-includes/bookmark.php
@@ -25,17 +25,16 @@ function get_link($bookmark_id, $output = OBJECT) {
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' => ''
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
+ 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) )
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index 6901a6b..695a986 100644
--- a/wp-includes/cache.php
+++ b/wp-includes/cache.php
@@ -1,458 +1,458 @@
-<?php
-function wp_cache_add($key, $data, $flag = '', $expire = 0) {
- global $wp_object_cache;
- $data = unserialize(serialize($data));
-
- return $wp_object_cache->add($key, $data, $flag, $expire);
-}
-
-function wp_cache_close() {
- global $wp_object_cache;
-
- if ( ! isset($wp_object_cache) )
- return;
- return $wp_object_cache->save();
-}
-
-function wp_cache_delete($id, $flag = '') {
- global $wp_object_cache;
-
- return $wp_object_cache->delete($id, $flag);
-}
-
-function wp_cache_flush() {
- global $wp_object_cache;
-
- return $wp_object_cache->flush();
-}
-
-function wp_cache_get($id, $flag = '') {
- global $wp_object_cache;
-
- return $wp_object_cache->get($id, $flag);
-}
-
-function wp_cache_init() {
- $GLOBALS['wp_object_cache'] =& new WP_Object_Cache();
-}
-
-function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
- global $wp_object_cache;
- $data = unserialize(serialize($data));
-
- return $wp_object_cache->replace($key, $data, $flag, $expire);
-}
-
-function wp_cache_set($key, $data, $flag = '', $expire = 0) {
- global $wp_object_cache;
- $data = unserialize(serialize($data));
-
- return $wp_object_cache->set($key, $data, $flag, $expire);
-}
-
-define('CACHE_SERIAL_HEADER', "<?php\n/*");
-define('CACHE_SERIAL_FOOTER', "*/\n?".">");
-
-class WP_Object_Cache {
- var $cache_dir;
- var $cache_enabled = false;
- var $expiration_time = 900;
- var $flock_filename = 'wp_object_cache.lock';
- var $mutex;
- var $cache = array ();
- var $dirty_objects = array ();
- var $non_existant_objects = array ();
- var $global_groups = array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details');
- var $blog_id;
- var $cold_cache_hits = 0;
- var $warm_cache_hits = 0;
- var $cache_misses = 0;
- var $secret = '';
-
- function acquire_lock() {
- // Acquire a write lock.
- $this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
- if ( false == $this->mutex)
- return false;
- flock($this->mutex, LOCK_EX);
- return true;
- }
-
- function key($key, $group) {
- global $blog_id;
-
- if ( empty($group) )
- $group = 'default';
-
- if (false !== array_search($group, $this->global_groups))
- $prefix = '';
- else
- $prefix = $blog_id . '-';
-
- if( '' != $key )
- $key = '-' . $key;
-
- return "$prefix$group$key";
- }
-
-
- function add($id, $data, $group = 'default', $expire = '') {
- if (empty ($group))
- $group = 'default';
-
- if (false !== $this->get($id, $group, false))
- return false;
-
- return $this->set($id, $data, $group, $expire);
- }
-
- function delete($id, $group = 'default', $force = false) {
- $hash = $this->key($id, $group);
- if (empty ($group))
- $group = 'default';
-
- if (!$force && false === $this->get($id, $group, false))
- return false;
-
- unset ($this->cache[$hash]);
- $this->non_existant_objects[$hash] = true;
- $this->dirty_objects[$this->key( '', $group )][] = $id;
- return true;
- }
-
- function flush() {
- if ( !$this->cache_enabled )
- return true;
-
- if ( ! $this->acquire_lock() )
- return false;
-
- $this->rm_cache_dir();
- $this->cache = array ();
- $this->dirty_objects = array ();
- $this->non_existant_objects = array ();
-
- $this->release_lock();
-
- return true;
- }
-
- function get($id, $group = 'default', $count_hits = true) {
- $hash = $this->key($id, $group);
- $group_key = $this->key( '', $group );
- if (empty ($group))
- $group = 'default';
-
- if (isset ($this->cache[$hash])) {
- if ($count_hits)
- $this->warm_cache_hits += 1;
- return $this->cache[$hash];
- }
-
- if (isset ($this->non_existant_objects[$hash]))
- return false;
-
- // If caching is not enabled, we have to fall back to pulling from the DB.
- if (!$this->cache_enabled) {
- if (!isset ($this->cache[$group_key]))
- $this->load_group_from_db($group_key);
-
- if (isset ($this->cache[$hash])) {
- $this->cold_cache_hits += 1;
- return $this->cache[$hash];
- }
-
- $this->non_existant_objects[$hash] = true;
- $this->cache_misses += 1;
- return false;
- }
-
- $cache_file = $this->cache_dir.$this->get_group_dir($group_key)."/".$this->hash($hash).'.php';
- if (!file_exists($cache_file)) {
- $this->non_existant_objects[$hash] = true;
- $this->cache_misses += 1;
- return false;
- }
-
- // If the object has expired, remove it from the cache and return false to force
- // a refresh.
- $now = time();
- if ((filemtime($cache_file) + $this->expiration_time) <= $now) {
- $this->cache_misses += 1;
- $this->delete($id, $group, true);
- return false;
- }
-
- $this->cache[$hash] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))));
- if (false === $this->cache[$hash])
- $this->cache[$hash] = '';
-
- $this->cold_cache_hits += 1;
- return $this->cache[$hash];
- }
-
- function get_group_dir($group) {
- if (false !== array_search($group, $this->global_groups))
- return $group;
-
- return "{$this->blog_id}/$group";
- }
-
- function hash($data) {
- if ( function_exists('hash_hmac') ) {
- return hash_hmac('md5', $data, $this->secret);
- } else {
- return md5($data . $this->secret);
- }
- }
-
- function load_group_from_db($group) {
- global $wpdb;
-
- if ('category' == $group) {
- $this->cache['category'] = array ();
- if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) {
- foreach ($dogs as $catt) {
- $this->cache['category'][$catt->cat_ID] = $catt;
- $this->cache[$this->key( $catt->cat_ID, 'category' )] = $catt;
- }
- }
- }
-
- }
-
- function make_group_dir($group, $perms) {
- $group_dir = $this->get_group_dir($group);
- $make_dir = '';
- foreach (split('/', $group_dir) as $subdir) {
- $make_dir .= "$subdir/";
- if (!file_exists($this->cache_dir.$make_dir)) {
- if (! @ mkdir($this->cache_dir.$make_dir))
- break;
- @ chmod($this->cache_dir.$make_dir, $perms);
- }
-
- if (!file_exists($this->cache_dir.$make_dir."index.php")) {
- $file_perms = $perms & 0000666;
- @ touch($this->cache_dir.$make_dir."index.php");
- @ chmod($this->cache_dir.$make_dir."index.php", $file_perms);
- }
- }
-
- return $this->cache_dir."$group_dir/";
- }
-
- function rm_cache_dir() {
- $dir = $this->cache_dir;
- $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)
- return false;
-
- while (($file = @ readdir($dh)) !== false) {
- if ($file == '.' or $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($stack as $dir) {
- if ( $dir != $top_dir)
- @ rmdir($dir);
- }
-
- }
-
- function release_lock() {
- // Release write lock.
- flock($this->mutex, LOCK_UN);
- fclose($this->mutex);
- }
-
- function replace($id, $data, $group = 'default', $expire = '') {
- if (empty ($group))
- $group = 'default';
-
- if (false === $this->get($id, $group, false))
- return false;
-
- return $this->set($id, $data, $group, $expire);
- }
-
- function set($id, $data, $group = 'default', $expire = '') {
- $hash = $this->key($id, $group);
- if (empty ($group))
- $group = 'default';
-
- if (NULL == $data)
- $data = '';
-
- $this->cache[$hash] = $data;
- unset ($this->non_existant_objects[$hash]);
- $this->dirty_objects[$this->key( '', $group )][] = $id;
-
- return true;
- }
-
- function save() {
- //$this->stats();
-
- if (!$this->cache_enabled)
- return true;
-
- if (empty ($this->dirty_objects))
- return true;
-
- // Give the new dirs the same perms as wp-content.
- $stat = stat(ABSPATH.'wp-content');
- $dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
- $file_perms = $dir_perms & 0000666; // Remove execute bits for files.
-
- // Make the base cache dir.
- if (!file_exists($this->cache_dir)) {
- if (! @ mkdir($this->cache_dir))
- return false;
- @ chmod($this->cache_dir, $dir_perms);
- }
-
- if (!file_exists($this->cache_dir."index.php")) {
- @ touch($this->cache_dir."index.php");
- @ chmod($this->cache_dir."index.php", $file_perms);
- }
-
- if ( ! $this->acquire_lock() )
- return false;
-
- // Loop over dirty objects and save them.
- $errors = 0;
- foreach ($this->dirty_objects as $group => $ids) {
- $group_dir = $this->make_group_dir($group, $dir_perms);
-
- $ids = array_unique($ids);
- foreach ($ids as $id) {
- $cache_file = $group_dir.$this->hash($group.'-'.$id).'.php';
-
- // Remove the cache file if the key is not set.
- if (!isset ($this->cache[$group.'-'.$id])) {
- if (file_exists($cache_file))
- @ unlink($cache_file);
- continue;
- }
-
- $temp_file = tempnam($group_dir, 'tmp');
- $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group.'-'.$id])).CACHE_SERIAL_FOOTER;
- $fd = @fopen($temp_file, 'w');
- if ( false === $fd ) {
- $errors++;
- continue;
- }
- fputs($fd, $serial);
- fclose($fd);
- if (!@ rename($temp_file, $cache_file)) {
- if (!@ copy($temp_file, $cache_file))
- $errors++;
- @ unlink($temp_file);
- }
- @ chmod($cache_file, $file_perms);
- }
- }
-
- $this->dirty_objects = array();
-
- $this->release_lock();
-
- if ( $errors )
- return false;
-
- return true;
- }
-
- function stats() {
- echo "<p>";
- echo "<strong>Cold Cache Hits:</strong> {$this->cold_cache_hits}<br/>";
- echo "<strong>Warm Cache Hits:</strong> {$this->warm_cache_hits}<br/>";
- echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br/>";
- echo "</p>";
-
- foreach ($this->cache as $group => $cache) {
- echo "<p>";
- echo "<strong>Group:</strong> $group<br/>";
- echo "<strong>Cache:</strong>";
- echo "<pre>";
- print_r($cache);
- echo "</pre>";
- if (isset ($this->dirty_objects[$group])) {
- echo "<strong>Dirty Objects:</strong>";
- echo "<pre>";
- print_r(array_unique($this->dirty_objects[$group]));
- echo "</pre>";
- echo "</p>";
- }
- }
- }
-
- function WP_Object_Cache() {
- return $this->__construct();
- }
-
- function __construct() {
- global $blog_id;
-
- register_shutdown_function(array(&$this, "__destruct"));
-
- if (defined('DISABLE_CACHE'))
- return;
-
- if ( ! defined('ENABLE_CACHE') )
- return;
-
- // Disable the persistent cache if safe_mode is on.
- if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
- return;
-
- if (defined('CACHE_PATH'))
- $this->cache_dir = CACHE_PATH;
- else
- // Using the correct separator eliminates some cache flush errors on Windows
- $this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
-
- if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) {
- $this->cache_enabled = true;
- } else {
- if (is_writable(ABSPATH.'wp-content')) {
- $this->cache_enabled = true;
- }
- }
-
- if (defined('CACHE_EXPIRATION_TIME'))
- $this->expiration_time = CACHE_EXPIRATION_TIME;
-
- if ( defined('WP_SECRET') )
- $this->secret = WP_SECRET;
- else
- $this->secret = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
-
- $this->blog_id = $this->hash($blog_id);
- }
-
- function __destruct() {
- $this->save();
- return true;
- }
-}
-?>
+<?php
+function wp_cache_add($key, $data, $flag = '', $expire = 0) {
+ global $wp_object_cache;
+ $data = unserialize(serialize($data));
+
+ return $wp_object_cache->add($key, $data, $flag, $expire);
+}
+
+function wp_cache_close() {
+ global $wp_object_cache;
+
+ if ( ! isset($wp_object_cache) )
+ return;
+ return $wp_object_cache->save();
+}
+
+function wp_cache_delete($id, $flag = '') {
+ global $wp_object_cache;
+
+ return $wp_object_cache->delete($id, $flag);
+}
+
+function wp_cache_flush() {
+ global $wp_object_cache;
+
+ return $wp_object_cache->flush();
+}
+
+function wp_cache_get($id, $flag = '') {
+ global $wp_object_cache;
+
+ return $wp_object_cache->get($id, $flag);
+}
+
+function wp_cache_init() {
+ $GLOBALS['wp_object_cache'] =& new WP_Object_Cache();
+}
+
+function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
+ global $wp_object_cache;
+ $data = unserialize(serialize($data));
+
+ return $wp_object_cache->replace($key, $data, $flag, $expire);
+}
+
+function wp_cache_set($key, $data, $flag = '', $expire = 0) {
+ global $wp_object_cache;
+ $data = unserialize(serialize($data));
+
+ return $wp_object_cache->set($key, $data, $flag, $expire);
+}
+
+define('CACHE_SERIAL_HEADER', "<?php\n/*");
+define('CACHE_SERIAL_FOOTER', "*/\n?".">");
+
+class WP_Object_Cache {
+ var $cache_dir;
+ var $cache_enabled = false;
+ var $expiration_time = 900;
+ var $flock_filename = 'wp_object_cache.lock';
+ var $mutex;
+ var $cache = array ();
+ var $dirty_objects = array ();
+ var $non_existant_objects = array ();
+ var $global_groups = array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details');
+ var $blog_id;
+ var $cold_cache_hits = 0;
+ var $warm_cache_hits = 0;
+ var $cache_misses = 0;
+ var $secret = '';
+
+ function acquire_lock() {
+ // Acquire a write lock.
+ $this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
+ if ( false == $this->mutex)
+ return false;
+ flock($this->mutex, LOCK_EX);
+ return true;
+ }
+
+ function key($key, $group) {
+ global $blog_id;
+
+ if ( empty($group) )
+ $group = 'default';
+
+ if (false !== array_search($group, $this->global_groups))
+ $prefix = '';
+ else
+ $prefix = $blog_id . '-';
+
+ if( '' != $key )
+ $key = '-' . $key;
+
+ return "$prefix$group$key";
+ }
+
+
+ function add($id, $data, $group = 'default', $expire = '') {
+ if (empty ($group))
+ $group = 'default';
+
+ if (false !== $this->get($id, $group, false))
+ return false;
+
+ return $this->set($id, $data, $group, $expire);
+ }
+
+ function delete($id, $group = 'default', $force = false) {
+ $hash = $this->key($id, $group);
+ if (empty ($group))
+ $group = 'default';
+
+ if (!$force && false === $this->get($id, $group, false))
+ return false;
+
+ unset ($this->cache[$hash]);
+ $this->non_existant_objects[$hash] = true;
+ $this->dirty_objects[$this->key( '', $group )][] = $id;
+ return true;
+ }
+
+ function flush() {
+ if ( !$this->cache_enabled )
+ return true;
+
+ if ( ! $this->acquire_lock() )
+ return false;
+
+ $this->rm_cache_dir();
+ $this->cache = array ();
+ $this->dirty_objects = array ();
+ $this->non_existant_objects = array ();
+
+ $this->release_lock();
+
+ return true;
+ }
+
+ function get($id, $group = 'default', $count_hits = true) {
+ $hash = $this->key($id, $group);
+ $group_key = $this->key( '', $group );
+ if (empty ($group))
+ $group = 'default';
+
+ if (isset ($this->cache[$hash])) {
+ if ($count_hits)
+ $this->warm_cache_hits += 1;
+ return $this->cache[$hash];
+ }
+
+ if (isset ($this->non_existant_objects[$hash]))
+ return false;
+
+ // If caching is not enabled, we have to fall back to pulling from the DB.
+ if (!$this->cache_enabled) {
+ if (!isset ($this->cache[$group_key]))
+ $this->load_group_from_db($group_key);
+
+ if (isset ($this->cache[$hash])) {
+ $this->cold_cache_hits += 1;
+ return $this->cache[$hash];
+ }
+
+ $this->non_existant_objects[$hash] = true;
+ $this->cache_misses += 1;
+ return false;
+ }
+
+ $cache_file = $this->cache_dir.$this->get_group_dir($group_key)."/".$this->hash($hash).'.php';
+ if (!file_exists($cache_file)) {
+ $this->non_existant_objects[$hash] = true;
+ $this->cache_misses += 1;
+ return false;
+ }
+
+ // If the object has expired, remove it from the cache and return false to force
+ // a refresh.
+ $now = time();
+ if ((filemtime($cache_file) + $this->expiration_time) <= $now) {
+ $this->cache_misses += 1;
+ $this->delete($id, $group, true);
+ return false;
+ }
+
+ $this->cache[$hash] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))));
+ if (false === $this->cache[$hash])
+ $this->cache[$hash] = '';
+
+ $this->cold_cache_hits += 1;
+ return $this->cache[$hash];
+ }
+
+ function get_group_dir($group) {
+ if (false !== array_search($group, $this->global_groups))
+ return $group;
+
+ return "{$this->blog_id}/$group";
+ }
+
+ function hash($data) {
+ if ( function_exists('hash_hmac') ) {
+ return hash_hmac('md5', $data, $this->secret);
+ } else {
+ return md5($data . $this->secret);
+ }
+ }
+
+ function load_group_from_db($group) {
+ global $wpdb;
+
+ if ('category' == $group) {
+ $this->cache['category'] = array ();
+ if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) {
+ foreach ($dogs as $catt) {
+ $this->cache['category'][$catt->cat_ID] = $catt;
+ $this->cache[$this->key( $catt->cat_ID, 'category' )] = $catt;
+ }
+ }
+ }
+
+ }
+
+ function make_group_dir($group, $perms) {
+ $group_dir = $this->get_group_dir($group);
+ $make_dir = '';
+ foreach (split('/', $group_dir) as $subdir) {
+ $make_dir .= "$subdir/";
+ if (!file_exists($this->cache_dir.$make_dir)) {
+ if (! @ mkdir($this->cache_dir.$make_dir))
+ break;
+ @ chmod($this->cache_dir.$make_dir, $perms);
+ }
+
+ if (!file_exists($this->cache_dir.$make_dir."index.php")) {
+ $file_perms = $perms & 0000666;
+ @ touch($this->cache_dir.$make_dir."index.php");
+ @ chmod($this->cache_dir.$make_dir."index.php", $file_perms);
+ }
+ }
+
+ return $this->cache_dir."$group_dir/";
+ }
+
+ function rm_cache_dir() {
+ $dir = $this->cache_dir;
+ $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)
+ return false;
+
+ while (($file = @ readdir($dh)) !== false) {
+ if ($file == '.' or $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($stack as $dir) {
+ if ( $dir != $top_dir)
+ @ rmdir($dir);
+ }
+
+ }
+
+ function release_lock() {
+ // Release write lock.
+ flock($this->mutex, LOCK_UN);
+ fclose($this->mutex);
+ }
+
+ function replace($id, $data, $group = 'default', $expire = '') {
+ if (empty ($group))
+ $group = 'default';
+
+ if (false === $this->get($id, $group, false))
+ return false;
+
+ return $this->set($id, $data, $group, $expire);
+ }
+
+ function set($id, $data, $group = 'default', $expire = '') {
+ $hash = $this->key($id, $group);
+ if (empty ($group))
+ $group = 'default';
+
+ if (NULL == $data)
+ $data = '';
+
+ $this->cache[$hash] = $data;
+ unset ($this->non_existant_objects[$hash]);
+ $this->dirty_objects[$this->key( '', $group )][] = $id;
+
+ return true;
+ }
+
+ function save() {
+ //$this->stats();
+
+ if (!$this->cache_enabled)
+ return true;
+
+ if (empty ($this->dirty_objects))
+ return true;
+
+ // Give the new dirs the same perms as wp-content.
+ $stat = stat(ABSPATH.'wp-content');
+ $dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
+ $file_perms = $dir_perms & 0000666; // Remove execute bits for files.
+
+ // Make the base cache dir.
+ if (!file_exists($this->cache_dir)) {
+ if (! @ mkdir($this->cache_dir))
+ return false;
+ @ chmod($this->cache_dir, $dir_perms);
+ }
+
+ if (!file_exists($this->cache_dir."index.php")) {
+ @ touch($this->cache_dir."index.php");
+ @ chmod($this->cache_dir."index.php", $file_perms);
+ }
+
+ if ( ! $this->acquire_lock() )
+ return false;
+
+ // Loop over dirty objects and save them.
+ $errors = 0;
+ foreach ($this->dirty_objects as $group => $ids) {
+ $group_dir = $this->make_group_dir($group, $dir_perms);
+
+ $ids = array_unique($ids);
+ foreach ($ids as $id) {
+ $cache_file = $group_dir.$this->hash($group.'-'.$id).'.php';
+
+ // Remove the cache file if the key is not set.
+ if (!isset ($this->cache[$group.'-'.$id])) {
+ if (file_exists($cache_file))
+ @ unlink($cache_file);
+ continue;
+ }
+
+ $temp_file = tempnam($group_dir, 'tmp');
+ $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group.'-'.$id])).CACHE_SERIAL_FOOTER;
+ $fd = @fopen($temp_file, 'w');
+ if ( false === $fd ) {
+ $errors++;
+ continue;
+ }
+ fputs($fd, $serial);
+ fclose($fd);
+ if (!@ rename($temp_file, $cache_file)) {
+ if (!@ copy($temp_file, $cache_file))
+ $errors++;
+ @ unlink($temp_file);
+ }
+ @ chmod($cache_file, $file_perms);
+ }
+ }
+
+ $this->dirty_objects = array();
+
+ $this->release_lock();
+
+ if ( $errors )
+ return false;
+
+ return true;
+ }
+
+ function stats() {
+ echo "<p>";
+ echo "<strong>Cold Cache Hits:</strong> {$this->cold_cache_hits}<br/>";
+ echo "<strong>Warm Cache Hits:</strong> {$this->warm_cache_hits}<br/>";
+ echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br/>";
+ echo "</p>";
+
+ foreach ($this->cache as $group => $cache) {
+ echo "<p>";
+ echo "<strong>Group:</strong> $group<br/>";
+ echo "<strong>Cache:</strong>";
+ echo "<pre>";
+ print_r($cache);
+ echo "</pre>";
+ if (isset ($this->dirty_objects[$group])) {
+ echo "<strong>Dirty Objects:</strong>";
+ echo "<pre>";
+ print_r(array_unique($this->dirty_objects[$group]));
+ echo "</pre>";
+ echo "</p>";
+ }
+ }
+ }
+
+ function WP_Object_Cache() {
+ return $this->__construct();
+ }
+
+ function __construct() {
+ global $blog_id;
+
+ register_shutdown_function(array(&$this, "__destruct"));
+
+ if (defined('DISABLE_CACHE'))
+ return;
+
+ if ( ! defined('ENABLE_CACHE') )
+ return;
+
+ // Disable the persistent cache if safe_mode is on.
+ if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
+ return;
+
+ if (defined('CACHE_PATH'))
+ $this->cache_dir = CACHE_PATH;
+ else
+ // Using the correct separator eliminates some cache flush errors on Windows
+ $this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
+
+ if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) {
+ $this->cache_enabled = true;
+ } else {
+ if (is_writable(ABSPATH.'wp-content')) {
+ $this->cache_enabled = true;
+ }
+ }
+
+ if (defined('CACHE_EXPIRATION_TIME'))
+ $this->expiration_time = CACHE_EXPIRATION_TIME;
+
+ if ( defined('WP_SECRET') )
+ $this->secret = WP_SECRET;
+ else
+ $this->secret = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
+
+ $this->blog_id = $this->hash($blog_id);
+ }
+
+ function __destruct() {
+ $this->save();
+ return true;
+ }
+}
+?>
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
index d4c521e..5eaabfb 100644
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -86,6 +86,15 @@ function _get_the_category_usort($a, $b) {
return strcmp($a->category_name, $b->category_name);
}
+function _get_the_category_usort_by_ID($a, $b) {
+ if ( $a->cat_ID > $b->cat_ID )
+ return 1;
+ elseif ( $a->cat_ID < $b->cat_ID )
+ return -1;
+ else
+ return 0;
+}
+
function get_the_category_by_ID($cat_ID) {
$cat_ID = (int) $cat_ID;
$category = &get_category($cat_ID);
@@ -172,21 +181,20 @@ function category_description($category = 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', 'class' => 'postform'
- );
-
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $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',
+ 'class' => 'postform');
$defaults['selected'] = ( is_category() ) ? get_query_var('cat') : 0;
-
- $r = wp_parse_args( $args, $defaults );
+ $r = array_merge($defaults, $r);
$r['include_last_update_time'] = $r['show_last_update'];
- extract( $r );
+ extract($r, EXTR_SKIP);
$categories = get_categories($r);
@@ -222,28 +230,23 @@ function wp_dropdown_categories($args = '') {
}
function wp_list_categories($args = '') {
- $defaults = array(
- 'show_option_all' => '', '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_image' => '', 'exclude' => '',
- 'hierarchical' => true, 'title_li' => __('Categories')
- );
-
- $r = wp_parse_args( $args, $defaults );
-
- if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('show_option_all' => '', '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_image' => '', 'exclude' => '',
+ 'hierarchical' => true, 'title_li' => __('Categories'));
+ $r = array_merge($defaults, $r);
+ if ( !isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'] )
$r['pad_counts'] = true;
- }
-
- if ( isset( $r['show_date'] ) ) {
+ if ( isset($r['show_date']) )
$r['include_last_update_time'] = $r['show_date'];
- }
-
- extract( $r );
-
+ extract($r, EXTR_SKIP);
+
$categories = get_categories($r);
$output = '';
diff --git a/wp-includes/category.php b/wp-includes/category.php
index b14685d..fcfb60f 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -5,7 +5,7 @@ function get_all_category_ids() {
if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
$cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
- wp_cache_set('all_category_ids', $cat_ids, 'category');
+ wp_cache_add('all_category_ids', $cat_ids, 'category');
}
return $cat_ids;
@@ -13,25 +13,22 @@ function get_all_category_ids() {
function &get_categories($args = '') {
global $wpdb, $category_links;
-
- $defaults = array(
- 'type' => 'post', 'child_of' => 0,
- 'orderby' => 'name', 'order' => 'ASC',
- 'hide_empty' => true, 'include_last_update_time' => false,
- 'hierarchical' => 1, 'exclude' => '',
- 'include' => '', 'number' => '',
- 'pad_counts' => false
- );
-
- $r = wp_parse_args( $args, $defaults );
-
- if ( $r['orderby'] == 'count' ) {
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
+ 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '',
+ 'number' => '', 'pad_counts' => false);
+ $r = array_merge($defaults, $r);
+ if ( 'count' == $r['orderby'] )
$r['orderby'] = 'category_count';
- } else {
- $r['orderby'] = 'cat_' . $r['orderby'];
- }
-
- extract( $r );
+ else
+ $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields
+ $r['number'] = (int) $r['number'];
+ extract($r, EXTR_SKIP);
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_categories', 'category' ) )
@@ -82,8 +79,6 @@ function &get_categories($args = '') {
$where .= ' AND category_count > 0';
}
-
-
if ( !empty($number) )
$number = 'LIMIT ' . $number;
else
@@ -137,7 +132,7 @@ function &get_categories($args = '') {
reset ( $categories );
$cache[ $key ] = $categories;
- wp_cache_set( 'get_categories', $cache, 'category' );
+ wp_cache_add( 'get_categories', $cache, 'category' );
$categories = apply_filters('get_categories', $categories, $r);
return $categories;
@@ -158,7 +153,7 @@ function &get_category(&$category, $output = OBJECT) {
$category = (int) $category;
if ( ! $_category = wp_cache_get($category, 'category') ) {
$_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
- wp_cache_set($category, $_category, 'category');
+ wp_cache_add($category, $_category, 'category');
}
}
@@ -211,15 +206,6 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE
return NULL;
}
-function get_category_by_slug( $slug ) {
- global $wpdb;
- $slug = sanitize_title( $slug );
- if ( empty( $slug ) )
- return false;
- $category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " );
- return get_category( $category );
-}
-
// Get the ID of a category from its name
function get_cat_ID($cat_name='General') {
global $wpdb;
@@ -342,5 +328,4 @@ function _get_category_hierarchy() {
return $children;
}
-
?>
diff --git a/wp-includes/class-phpmailer.php b/wp-includes/class-phpmailer.php
index ad439fe..4c93bae 100644
--- a/wp-includes/class-phpmailer.php
+++ b/wp-includes/class-phpmailer.php
@@ -390,7 +390,7 @@ class PHPMailer
*/
function SendmailSend($header, $body) {
if ($this->Sender != "")
- $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
+ $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, escapeshellarg($this->Sender));
else
$sendmail = sprintf("%s -oi -t", $this->Sendmail);
diff --git a/wp-includes/class-snoopy.php b/wp-includes/class-snoopy.php
index 5e88787..9bf56b3 100644
--- a/wp-includes/class-snoopy.php
+++ b/wp-includes/class-snoopy.php
@@ -796,7 +796,7 @@ class Snoopy
$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)
+ if(!empty($this->port))
$headers .= ":".$this->port;
$headers .= "\r\n";
}
diff --git a/wp-includes/classes.php b/wp-includes/classes.php
index 3ca1926..dd05256 100644
--- a/wp-includes/classes.php
+++ b/wp-includes/classes.php
@@ -506,7 +506,7 @@ class Walker_Page extends Walker {
function start_el($output, $page, $depth, $current_page, $args) {
if ( $depth )
$indent = str_repeat("\t", $depth);
- extract($args);
+ extract($args, EXTR_SKIP);
$css_class = 'page_item';
$_current_page = get_page( $current_page );
if ( $page->ID == $current_page )
@@ -687,14 +687,16 @@ class WP_Ajax_Response {
// a WP_Error object can be passed in 'id' or 'data'
function add( $args = '' ) {
- $defaults = array(
- 'what' => 'object', 'action' => false,
- 'id' => '0', 'old_id' => false,
- 'data' => '', 'supplemental' => array()
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('what' => 'object', 'action' => false, 'id' => '0', 'old_id' => false,
+ 'data' => '', 'supplemental' => array());
+
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
if ( is_wp_error($id) ) {
$data = $id;
diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index ed41bb6..086c782 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -239,7 +239,7 @@ function trackback_url( $display = true ) {
function trackback_rdf($timezone = 0) {
global $id;
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) {
+ if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) {
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/">
@@ -285,7 +285,7 @@ function comments_template( $file = '/comments.php' ) {
$req = get_option('require_name_email');
$commenter = wp_get_current_commenter();
- extract($commenter);
+ extract($commenter, EXTR_SKIP);
// TODO: Use API instead of SELECTs.
if ( $user_ID) {
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index b1aee83..82a00ab 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -73,20 +73,16 @@ function get_approved_comments($post_id) {
function &get_comment(&$comment, $output = OBJECT) {
global $comment_cache, $wpdb;
- if ( empty($comment) ) {
- if ( isset($GLOBALS['comment']) )
- $_comment = & $GLOBALS['comment'];
- else
- $_comment = null;
- } elseif ( is_object($comment) ) {
+ if ( empty($comment) )
+ return null;
+
+ if ( is_object($comment) ) {
if ( !isset($comment_cache[$comment->comment_ID]) )
$comment_cache[$comment->comment_ID] = &$comment;
$_comment = & $comment_cache[$comment->comment_ID];
} else {
$comment = (int) $comment;
- if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) {
- $_comment = & $GLOBALS['comment'];
- } elseif ( !isset($comment_cache[$comment]) ) {
+ if ( !isset($comment_cache[$comment]) ) {
$_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
$comment_cache[$comment->comment_ID] = & $_comment;
} else {
@@ -182,7 +178,7 @@ function sanitize_comment_cookies() {
function wp_allow_comment($commentdata) {
global $wpdb;
- extract($commentdata);
+ extract($commentdata, EXTR_SKIP);
// Simple duplicate check
$dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' ";
@@ -329,7 +325,7 @@ function wp_get_current_commenter() {
function wp_insert_comment($commentdata) {
global $wpdb;
- extract($commentdata);
+ extract($commentdata, EXTR_SKIP);
if ( ! isset($comment_author_IP) )
$comment_author_IP = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] );
@@ -461,7 +457,7 @@ function wp_update_comment($commentarr) {
$commentarr = wp_filter_comment( $commentarr );
// Now extract the merged array.
- extract($commentarr);
+ extract($commentarr, EXTR_SKIP);
$comment_content = apply_filters('comment_save_pre', $comment_content);
@@ -521,7 +517,7 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
$x_pingback_str = 'x-pingback: ';
$pingback_href_original_pos = 27;
- extract(parse_url($url));
+ extract(parse_url($url), EXTR_SKIP);
if ( !isset($host) ) // Not an URL. This should never happen.
return false;
@@ -676,7 +672,9 @@ function pingback($content, $post_ID) {
include_once(ABSPATH . WPINC . '/class-IXR.php');
// original code by Mort (http://mort.mine.nu:8080)
+ $log = debug_fopen(ABSPATH . '/pingback.log', 'a');
$post_links = array();
+ debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n");
$pung = get_pung($post_ID);
@@ -692,6 +690,10 @@ function pingback($content, $post_ID) {
// 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);
+ // Debug
+ debug_fwrite($log, 'Post contents:');
+ debug_fwrite($log, $content."\n");
+
// Step 2.
// Walking thru the links array
// first we get rid of links pointing to sites, not to specific files
@@ -715,12 +717,16 @@ function pingback($content, $post_ID) {
do_action_ref_array('pre_ping', array(&$post_links, &$pung));
foreach ( (array) $post_links as $pagelinkedto ) {
+ debug_fwrite($log, "Processing -- $pagelinkedto\n");
$pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
if ( $pingback_server_url ) {
@ set_time_limit( 60 );
// Now, the RPC call
+ debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
+ debug_fwrite($log, 'Page Linked From: ');
$pagelinkedfrom = get_permalink($post_ID);
+ debug_fwrite($log, $pagelinkedfrom."\n");
// using a timeout of 3 seconds should be enough to cover slow servers
$client = new IXR_Client($pingback_server_url);
@@ -732,8 +738,13 @@ function pingback($content, $post_ID) {
if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) )
add_ping( $post_ID, $pagelinkedto );
+ else
+ debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
}
}
+
+ debug_fwrite($log, "\nEND: ".time()."\n****************************\n");
+ debug_fclose($log);
}
@@ -770,6 +781,16 @@ function trackback($trackback_url, $title, $excerpt, $ID) {
$trackback_url['port'] = 80;
$fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
@fputs($fs, $http_request);
+/*
+ $debug_file = 'trackback.log';
+ $fp = fopen($debug_file, 'a');
+ fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
+ while(!@feof($fs)) {
+ fwrite($fp, @fgets($fs, 4096));
+ }
+ fwrite($fp, "\n\n");
+ fclose($fp);
+*/
@fclose($fs);
$tb_url = addslashes( $tb_url );
@@ -794,4 +815,4 @@ function weblog_ping($server = '', $path = '') {
$client->query('weblogUpdates.ping', get_option('blogname'), $home);
}
-?> \ No newline at end of file
+?>
diff --git a/wp-includes/compat.php b/wp-includes/compat.php
index e68ec2a..b346fdd 100644
--- a/wp-includes/compat.php
+++ b/wp-includes/compat.php
@@ -73,7 +73,7 @@ if (!defined('CASE_UPPER')) {
* @link http://php.net/function.array_change_key_case
* @author Stephan Schmidt <schst@php.net>
* @author Aidan Lister <aidan@php.net>
- * @version $Revision: 4495 $
+ * @version $Revision: 5187 $
* @since PHP 4.2.0
* @require PHP 4.0.0 (user_error)
*/
diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php
index 0caba44..c93abe3 100644
--- a/wp-includes/deprecated.php
+++ b/wp-includes/deprecated.php
@@ -1,512 +1,515 @@
-<?php
-
-/*
- * Deprecated global variables.
- */
-
-$tableposts = $wpdb->posts;
-$tableusers = $wpdb->users;
-$tablecategories = $wpdb->categories;
-$tablepost2cat = $wpdb->post2cat;
-$tablecomments = $wpdb->comments;
-$tablelinks = $wpdb->links;
-$tablelinkcategories = 'linkcategories_is_gone';
-$tableoptions = $wpdb->options;
-$tablepostmeta = $wpdb->postmeta;
-
-/*
- * Deprecated functions come here to die.
- */
-
-// Use get_post().
-function get_postdata($postid) {
- $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;
-}
-
-// Use the new post loop.
-function start_wp() {
- global $wp_query, $post;
-
- // Since the old style loop is being used, advance the query iterator here.
- $wp_query->next_post();
-
- setup_postdata($post);
-}
-
-function the_category_ID($echo = true) {
- // Grab the first cat in the list.
- $categories = get_the_category();
- $cat = $categories[0]->cat_ID;
-
- if ( $echo )
- echo $cat;
-
- return $cat;
-}
-
-function the_category_head($before='', $after='') {
- global $currentcat, $previouscat;
- // 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;
- }
-}
-
-// Use previous_post_link().
-function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
-
- 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;
-}
-
-// Use next_post_link().
-function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
-
- 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;
-}
-
-//
-// Use current_user_can() for these.
-//
-
-/* returns true if $user_id can create a new post */
-function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
- $author_data = get_userdata($user_id);
- return ($author_data->user_level > 1);
-}
-
-/* returns true if $user_id can create a new post */
-function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
- $author_data = get_userdata($user_id);
- return ($author_data->user_level >= 1);
-}
-
-/* returns true if $user_id can edit $post_id */
-function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
- $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;
- }
-}
-
-/* returns true if $user_id can delete $post_id */
-function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
- // right now if one can edit, one can delete
- return user_can_edit_post($user_id, $post_id, $blog_id);
-}
-
-/* returns true if $user_id can set new posts' dates on $blog_id */
-function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
- $author_data = get_userdata($user_id);
- return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
-}
-
-/* returns true if $user_id can edit $post_id's date */
-function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
- $author_data = get_userdata($user_id);
- return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
-}
-
-/* returns true if $user_id can edit $post_id's comments */
-function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
- // 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);
-}
-
-/* returns true if $user_id can delete $post_id's comments */
-function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
- // right now if one can edit comments, one can delete comments
- return user_can_edit_post_comments($user_id, $post_id, $blog_id);
-}
-
-function user_can_edit_user($user_id, $other_user) {
- $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;
-}
-
-/** function get_linksbyname()
- ** Gets the links associated with category 'cat_name'.
- ** Parameters:
- ** cat_name (default 'noname') - The category name to use. If no
- ** match is found uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and it's description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - 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.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined
- ** show_rating (default false) - show rating stars/chars
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - 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) {
- global $wpdb;
- $cat_id = -1;
- $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
- if ($results) {
- foreach ($results as $result) {
- $cat_id = $result->cat_ID;
- }
- }
- get_links($cat_id, $before, $after, $between, $show_images, $orderby,
- $show_description, $show_rating, $limit, $show_updated);
-}
-
-/** function wp_get_linksbyname()
- ** Gets the links associated with the named category.
- ** Parameters:
- ** category (no default) - The category to use.
- **/
-function wp_get_linksbyname($category, $args = '') {
- global $wpdb;
-
- $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");
-
- if (! $cat_id)
- return;
-
- $args = add_query_arg('category', $cat_id, $args);
- wp_get_links($args);
-}
-
-/** function get_linkobjectsbyname()
- ** Gets an array of link objects associated with category 'cat_name'.
- ** Parameters:
- ** cat_name (default 'noname') - The category name to use. If no
- ** match is found uses all
- ** orderby (default 'id') - 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.
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- **
- ** Use this like:
- ** $links = get_linkobjectsbyname('fred');
- ** foreach ($links as $link) {
- ** echo '<li>'.$link->link_name.'</li>';
- ** }
- **/
-// Deprecate in favor of get_linkz().
-function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
- global $wpdb;
- $cat_id = -1;
- //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
- // TODO: Fix me.
- if ($results) {
- foreach ($results as $result) {
- $cat_id = $result->cat_id;
- }
- }
- return get_linkobjects($cat_id, $orderby, $limit);
-}
-
-/** function get_linkobjects()
- ** Gets an array of link objects associated with category n.
- ** Parameters:
- ** category (default -1) - The category to use. If no category supplied
- ** uses all
- ** orderby (default 'id') - 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.
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- **
- ** Use this like:
- ** $links = get_linkobjects(1);
- ** if ($links) {
- ** foreach ($links as $link) {
- ** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
- ** }
- ** }
- ** Fields are:
- ** 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
- **/
-// Deprecate in favor of get_linkz().
-function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
- global $wpdb;
-
- $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
- if ($category != -1) {
- $sql .= " AND link_category = $category ";
- }
- if ($orderby == '')
- $orderby = 'id';
- if (substr($orderby,0,1) == '_') {
- $direction = ' DESC';
- $orderby = substr($orderby,1);
- }
- if (strcasecmp('rand',$orderby) == 0) {
- $orderby = 'rand()';
- } else {
- $orderby = " link_" . $orderby;
- }
- $sql .= ' ORDER BY ' . $orderby;
- $sql .= $direction;
- /* The next 2 lines implement LIMIT TO processing */
- if ($limit != -1)
- $sql .= " LIMIT $limit";
-
- $results = $wpdb->get_results($sql);
- if ($results) {
- foreach ($results as $result) {
- $result->link_url = $result->link_url;
- $result->link_name = $result->link_name;
- $result->link_description = $result->link_description;
- $result->link_notes = $result->link_notes;
- $newresults[] = $result;
- }
- }
- return $newresults;
-}
-
-/** function get_linksbyname_withrating()
- ** Gets the links associated with category 'cat_name' and display rating stars/chars.
- ** Parameters:
- ** cat_name (default 'noname') - The category name to use. If no
- ** match is found uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and it's description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url' or 'description'. 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.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - 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) {
-
- get_linksbyname($cat_name, $before, $after, $between, $show_images,
- $orderby, $show_description, true, $limit, $show_updated);
-}
-
-/** function get_links_withrating()
- ** Gets the links associated with category n and display rating stars/chars.
- ** Parameters:
- ** category (default -1) - The category to use. If no category supplied
- ** uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and it's description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url' or 'description'. 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.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined .
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - 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) {
-
- get_links($category, $before, $after, $between, $show_images, $orderby,
- $show_description, true, $limit, $show_updated);
-}
-
-/** function get_get_autotoggle()
- ** Gets the auto_toggle setting of category n.
- ** Parameters: id (default 0) - The category to get. If no category supplied
- ** uses 0
- */
-function get_autotoggle($id = 0) {
- return 0;
-}
-
-// Use wp_list_cats().
-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) {
- $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);
-}
-
-function wp_list_cats($args = '') {
- $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);
-}
-
-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) {
-
- $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);
-}
-
-// Use wp_print_scripts() or WP_Scripts.
-function tinymce_include() {
- wp_print_script('wp_tiny_mce');
-}
-
-function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
- $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
- return wp_list_authors($args);
-}
-
-function wp_get_post_cats($blogid = '1', $post_ID = 0) {
- return wp_get_post_categories($post_ID);
-}
-
-function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
- return wp_set_post_categories($post_ID, $post_categories);
-}
-
-// Use wp_get_archives().
-function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
- $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
- return wp_get_archives($args);
-}
-
-// Use get_author_posts_url().
-function get_author_link($echo = false, $author_id, $author_nicename = '') {
- $link = get_author_posts_url($author_id, $author_nicename);
-
- if ( $echo )
- echo $link;
- return $link;
-}
-
-// Use wp_link_pages().
-function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
- $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
- return wp_link_pages($args);
-}
-
-// Use get_option().
-function get_settings($option) {
- return get_option($option);
-}
-
-?>
+<?php
+
+/*
+ * Deprecated global variables.
+ */
+
+$tableposts = $wpdb->posts;
+$tableusers = $wpdb->users;
+$tablecategories = $wpdb->categories;
+$tablepost2cat = $wpdb->post2cat;
+$tablecomments = $wpdb->comments;
+$tablelinks = $wpdb->links;
+$tablelinkcategories = 'linkcategories_is_gone';
+$tableoptions = $wpdb->options;
+$tablepostmeta = $wpdb->postmeta;
+
+/*
+ * Deprecated functions come here to die.
+ */
+
+// Use get_post().
+function get_postdata($postid) {
+ $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;
+}
+
+// Use the new post loop.
+function start_wp() {
+ global $wp_query, $post;
+
+ // Since the old style loop is being used, advance the query iterator here.
+ $wp_query->next_post();
+
+ setup_postdata($post);
+}
+
+function the_category_ID($echo = true) {
+ // Grab the first cat in the list.
+ $categories = get_the_category();
+ $cat = $categories[0]->cat_ID;
+
+ if ( $echo )
+ echo $cat;
+
+ return $cat;
+}
+
+function the_category_head($before='', $after='') {
+ global $currentcat, $previouscat;
+ // 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;
+ }
+}
+
+// Use previous_post_link().
+function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
+
+ 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;
+}
+
+// Use next_post_link().
+function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
+
+ 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;
+}
+
+//
+// Use current_user_can() for these.
+//
+
+/* returns true if $user_id can create a new post */
+function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return ($author_data->user_level > 1);
+}
+
+/* returns true if $user_id can create a new post */
+function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return ($author_data->user_level >= 1);
+}
+
+/* returns true if $user_id can edit $post_id */
+function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
+ $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;
+ }
+}
+
+/* returns true if $user_id can delete $post_id */
+function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit, one can delete
+ return user_can_edit_post($user_id, $post_id, $blog_id);
+}
+
+/* returns true if $user_id can set new posts' dates on $blog_id */
+function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
+ $author_data = get_userdata($user_id);
+ return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
+}
+
+/* returns true if $user_id can edit $post_id's date */
+function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
+ $author_data = get_userdata($user_id);
+ return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
+}
+
+/* returns true if $user_id can edit $post_id's comments */
+function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
+ // 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);
+}
+
+/* returns true if $user_id can delete $post_id's comments */
+function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
+ // right now if one can edit comments, one can delete comments
+ return user_can_edit_post_comments($user_id, $post_id, $blog_id);
+}
+
+function user_can_edit_user($user_id, $other_user) {
+ $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;
+}
+
+/** function get_linksbyname()
+ ** Gets the links associated with category 'cat_name'.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - 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.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined
+ ** show_rating (default false) - show rating stars/chars
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - 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) {
+ global $wpdb;
+ $cat_id = -1;
+ $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
+ if ($results) {
+ foreach ($results as $result) {
+ $cat_id = $result->cat_ID;
+ }
+ }
+ get_links($cat_id, $before, $after, $between, $show_images, $orderby,
+ $show_description, $show_rating, $limit, $show_updated);
+}
+
+/** function wp_get_linksbyname()
+ ** Gets the links associated with the named category.
+ ** Parameters:
+ ** category (no default) - The category to use.
+ **/
+function wp_get_linksbyname($category, $args = '') {
+ global $wpdb;
+
+ $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");
+
+ if (! $cat_id)
+ return;
+
+ $args = add_query_arg('category', $cat_id, $args);
+ wp_get_links($args);
+}
+
+/** function get_linkobjectsbyname()
+ ** Gets an array of link objects associated with category 'cat_name'.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** orderby (default 'id') - 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.
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ **
+ ** Use this like:
+ ** $links = get_linkobjectsbyname('fred');
+ ** foreach ($links as $link) {
+ ** echo '<li>'.$link->link_name.'</li>';
+ ** }
+ **/
+// Deprecate in favor of get_linkz().
+function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
+ global $wpdb;
+ $cat_id = -1;
+ //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
+ // TODO: Fix me.
+ if ($results) {
+ foreach ($results as $result) {
+ $cat_id = $result->cat_id;
+ }
+ }
+ return get_linkobjects($cat_id, $orderby, $limit);
+}
+
+/** function get_linkobjects()
+ ** Gets an array of link objects associated with category n.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** orderby (default 'id') - 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.
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ **
+ ** Use this like:
+ ** $links = get_linkobjects(1);
+ ** if ($links) {
+ ** foreach ($links as $link) {
+ ** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
+ ** }
+ ** }
+ ** Fields are:
+ ** 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
+ **/
+// Deprecate in favor of get_linkz().
+function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
+ global $wpdb;
+
+ $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
+ if ($category != -1) {
+ $sql .= " AND link_category = $category ";
+ }
+ if ($orderby == '')
+ $orderby = 'id';
+ if (substr($orderby,0,1) == '_') {
+ $direction = ' DESC';
+ $orderby = substr($orderby,1);
+ }
+ if (strcasecmp('rand',$orderby) == 0) {
+ $orderby = 'rand()';
+ } else {
+ $orderby = " link_" . $orderby;
+ }
+ $sql .= ' ORDER BY ' . $orderby;
+ $sql .= $direction;
+ /* The next 2 lines implement LIMIT TO processing */
+ if ($limit != -1)
+ $sql .= " LIMIT $limit";
+
+ $results = $wpdb->get_results($sql);
+ if ($results) {
+ foreach ($results as $result) {
+ $result->link_url = $result->link_url;
+ $result->link_name = $result->link_name;
+ $result->link_description = $result->link_description;
+ $result->link_notes = $result->link_notes;
+ $newresults[] = $result;
+ }
+ }
+ return $newresults;
+}
+
+/** function get_linksbyname_withrating()
+ ** Gets the links associated with category 'cat_name' and display rating stars/chars.
+ ** Parameters:
+ ** cat_name (default 'noname') - The category name to use. If no
+ ** match is found uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url' or 'description'. 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.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - 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) {
+
+ get_linksbyname($cat_name, $before, $after, $between, $show_images,
+ $orderby, $show_description, true, $limit, $show_updated);
+}
+
+/** function get_links_withrating()
+ ** Gets the links associated with category n and display rating stars/chars.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and it's description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url' or 'description'. 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.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined .
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - 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) {
+
+ get_links($category, $before, $after, $between, $show_images, $orderby,
+ $show_description, true, $limit, $show_updated);
+}
+
+/** function get_get_autotoggle()
+ ** Gets the auto_toggle setting of category n.
+ ** Parameters: id (default 0) - The category to get. If no category supplied
+ ** uses 0
+ */
+function get_autotoggle($id = 0) {
+ return 0;
+}
+
+// Use wp_list_cats().
+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) {
+ $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);
+}
+
+function wp_list_cats($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ // 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);
+}
+
+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) {
+
+ $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);
+}
+
+// Use wp_print_scripts() or WP_Scripts.
+function tinymce_include() {
+ wp_print_script('wp_tiny_mce');
+}
+
+function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
+ $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
+ return wp_list_authors($args);
+}
+
+function wp_get_post_cats($blogid = '1', $post_ID = 0) {
+ return wp_get_post_categories($post_ID);
+}
+
+function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
+ return wp_set_post_categories($post_ID, $post_categories);
+}
+
+// Use wp_get_archives().
+function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
+ $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
+ return wp_get_archives($args);
+}
+
+// Use get_author_posts_url().
+function get_author_link($echo = false, $author_id, $author_nicename = '') {
+ $link = get_author_posts_url($author_id, $author_nicename);
+
+ if ( $echo )
+ echo $link;
+ return $link;
+}
+
+// Use wp_link_pages().
+function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
+ $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
+ return wp_link_pages($args);
+}
+
+// Use get_option().
+function get_settings($option) {
+ return get_option($option);
+}
+
+?>
diff --git a/wp-includes/feed-atom-comments.php b/wp-includes/feed-atom-comments.php
index f7aaba8..0cde6e7 100644
--- a/wp-includes/feed-atom-comments.php
+++ b/wp-includes/feed-atom-comments.php
@@ -40,7 +40,7 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment();
printf(__('By: %s'), get_comment_author_rss());
}
?></title>
- <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('content_type'); ?>" />
+ <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
<author>
<name><?php comment_author_rss(); ?></name>
diff --git a/wp-includes/feed.php b/wp-includes/feed.php
index 4a0c5ac..3474ef3 100644
--- a/wp-includes/feed.php
+++ b/wp-includes/feed.php
@@ -151,13 +151,13 @@ function get_the_category_rss($type = 'rss') {
$home = get_bloginfo_rss('home');
$the_list = '';
foreach ( (array) $categories as $category ) {
- $category->cat_name = convert_chars($category->cat_name);
+ $cat_name = convert_chars($category->cat_name);
if ( 'rdf' == $type )
- $the_list .= "\n\t\t<dc:subject><![CDATA[$category->cat_name]]></dc:subject>\n";
+ $the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
if ( 'atom' == $type )
- $the_list .= "<category scheme='$home' term='$category->cat_name' />";
+ $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $category->cat_name ) );
else
- $the_list .= "\n\t\t<category><![CDATA[$category->cat_name]]></category>\n";
+ $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
}
return apply_filters('the_category_rss', $the_list, $type);
}
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index 14eb5b8..b251b6e 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -1103,7 +1103,7 @@ function htmlentities2($myHTML) {
// Escape single quotes, specialchar double quotes, and fix line endings.
function js_escape($text) {
$safe_text = wp_specialchars($text, 'double');
- $safe_text = str_replace('&#039;', "'", $safe_text);
+ $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
$safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
return apply_filters('js_escape', $safe_text, $text);
}
@@ -1118,4 +1118,11 @@ function wp_make_link_relative( $link ) {
return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
}
+function wp_parse_str( $string, &$array ) {
+ parse_str( $string, $array );
+ if ( get_magic_quotes_gpc() )
+ $array = stripslashes_deep( $array ); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
+ $array = apply_filters( 'wp_parse_str', $array );
+}
+
?>
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 32d251c..67787e1 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -83,14 +83,6 @@ function date_i18n($dateformatstring, $unixtimestamp) {
return $j;
}
-function number_format_i18n($number, $decimals = null) {
- global $wp_locale;
- // let the user override the precision only
- $decimals = is_null($decimals)? $wp_locale->number_format['decimals'] : intval($decimals);
-
- return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
-}
-
function get_weekstartend($mysqlstring, $start_of_week) {
$my = substr($mysqlstring,0,4);
$mm = substr($mysqlstring,8,2);
@@ -778,12 +770,12 @@ add_query_arg(associative_array, oldquery_or_uri)
function add_query_arg() {
$ret = '';
if ( is_array(func_get_arg(0)) ) {
- if ( @func_num_args() < 2 || '' == @func_get_arg(1) )
+ 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 || '' == @func_get_arg(2) )
+ if ( @func_num_args() < 3 || false === @func_get_arg(2) )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = @func_get_arg(2);
@@ -818,9 +810,7 @@ function add_query_arg() {
$query = $uri;
}
- parse_str($query, $qs);
- if ( get_magic_quotes_gpc() )
- $qs = stripslashes_deep($qs); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
+ wp_parse_str($query, $qs);
$qs = urlencode_deep($qs);
if ( is_array(func_get_arg(0)) ) {
$kayvees = func_get_arg(0);
@@ -841,7 +831,7 @@ function add_query_arg() {
}
$ret = trim($ret, '?');
$ret = $protocol . $base . $ret . $frag;
- $ret = trim($ret, '?');
+ $ret = rtrim($ret, '?');
return $ret;
}
@@ -855,7 +845,7 @@ remove_query_arg(removekey, [oldquery_or_uri]) or
remove_query_arg(removekeyarray, [oldquery_or_uri])
*/
-function remove_query_arg($key, $query='') {
+function remove_query_arg($key, $query=FALSE) {
if ( is_array($key) ) { // removing multiple keys
foreach ( (array) $key as $k )
$query = add_query_arg($k, FALSE, $query);
@@ -918,23 +908,19 @@ function wp($query_vars = '') {
$wp->main($query_vars);
}
-function get_status_header_desc( $code ) {
- global $wp_header_to_desc;
-
- $code = (int) $code;
-
- if ( isset( $wp_header_to_desc[$code] ) ) {
- return $wp_header_to_desc[$code];
- } else {
- return '';
- }
-}
-
function status_header( $header ) {
- $text = get_status_header_desc( $header );
-
- if ( empty( $text ) )
- return false;
+ if ( 200 == $header )
+ $text = 'OK';
+ elseif ( 301 == $header )
+ $text = 'Moved Permanently';
+ elseif ( 302 == $header )
+ $text = 'Moved Temporarily';
+ elseif ( 304 == $header )
+ $text = 'Not Modified';
+ elseif ( 404 == $header )
+ $text = 'Not Found';
+ elseif ( 410 == $header )
+ $text = 'Gone';
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) )
@@ -1216,7 +1202,6 @@ function wp_check_filetype($filename, $mimes = null) {
'js' => 'application/javascript',
'pdf' => 'application/pdf',
'doc' => 'application/msword',
- 'odt' => 'application/vnd.oasis.opendocument.text',
'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
'wri' => 'application/vnd.ms-write',
'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
@@ -1504,20 +1489,15 @@ function smilies_init() {
}
function wp_parse_args( $args, $defaults = '' ) {
- if ( is_array( $args ) ) {
+ if ( is_array( $args ) )
$r =& $args;
- } else {
- parse_str( $args, $r );
- if ( get_magic_quotes_gpc() ) {
- $r = stripslashes_deep( $r );
- }
- }
-
- if ( is_array( $defaults ) ) {
+ else
+ wp_parse_str( $args, $r );
+
+ if ( is_array( $defaults ) )
return array_merge( $defaults, $r );
- } else {
+ else
return $r;
- }
}
function wp_maybe_load_widgets() {
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index 7980319..bdc5b04 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -63,8 +63,8 @@ function bloginfo($show='') {
$info = get_bloginfo($show);
// Don't filter URL's.
- if (strpos($show, 'url') === false ||
- strpos($show, 'directory') === false ||
+ if (strpos($show, 'url') === false &&
+ strpos($show, 'directory') === false &&
strpos($show, 'home') === false) {
$info = apply_filters('bloginfo', $info, $show);
$info = convert_chars($info);
@@ -109,6 +109,7 @@ function get_bloginfo($show='') {
break;
case 'comments_atom_url':
$output = get_feed_link('comments_atom');
+ break;
case 'comments_rss2_url':
$output = get_feed_link('comments_rss2');
break;
@@ -217,8 +218,7 @@ function wp_title($sep = '&raquo;', $display = true) {
// If there is a post
if ( is_single() || is_page() ) {
$post = $wp_query->get_queried_object();
- $title = apply_filters('single_post_title', $title);
- $title = strip_tags($post->post_title);
+ $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
}
$prefix = '';
@@ -313,16 +313,16 @@ function get_archives_link($url, $text, $format = 'html', $before = '', $after =
function wp_get_archives($args = '') {
- global $wpdb, $wp_locale;
-
- $defaults = array(
- 'type' => 'monthly', 'limit' => '',
- 'format' => 'html', 'before' => '',
- 'after' => '', 'show_post_count' => false
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+ global $wp_locale, $wpdb;
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false);
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
if ( '' == $type )
$type = 'monthly';
@@ -900,10 +900,11 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
//<!--
edCanvas = document.getElementById('<?php echo $id; ?>');
<?php if ( $prev_id && user_can_richedit() ) : ?>
+ // If tinyMCE is defined.
+ if ( typeof tinyMCE != 'undefined' ) {
// This code is meant to allow tabbing from Title to Post (TinyMCE).
- if ( tinyMCE.isMSIE )
- document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e)
- {
+ if ( tinyMCE.isMSIE ) {
+ document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) {
e = e ? e : window.event;
if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
var i = tinyMCE.getInstanceById('<?php echo $id; ?>');
@@ -916,9 +917,8 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
return false;
}
}
- else
- document.getElementById('<?php echo $prev_id; ?>').onkeypress = function (e)
- {
+ } else {
+ document.getElementById('<?php echo $prev_id; ?>').onkeypress = function (e) {
e = e ? e : window.event;
if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
var i = tinyMCE.getInstanceById('<?php echo $id; ?>');
@@ -931,6 +931,8 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
return false;
}
}
+ }
+ }
<?php endif; ?>
//-->
</script>
@@ -956,27 +958,24 @@ function language_attributes() {
echo $output;
}
-function paginate_links( $arg = '' ) {
- if ( is_array($arg) )
- $a = &$arg;
- else
- parse_str($arg, $a);
-
- // Defaults
- $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; // How many numbers on either end including the end
- $mid_size = 2; // How many numbers to either side of current not including current
- $type = 'plain';
- $add_args = false; // array of query args to aadd
-
- extract($a);
+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, // How many numbers on either end including the end
+ 'mid_size' => 2, // How many numbers to either side of current not including current
+ 'type' => 'plain',
+ 'add_args' => false // array of query args to aadd
+ );
+
+ $args = wp_parse_args( $args, $defaults );
+ extract($args, EXTR_SKIP);
// Who knows what else people pass in $args
$total = (int) $total;
diff --git a/wp-includes/js/prototype.js b/wp-includes/js/prototype.js
index 842385a..6253917 100644
--- a/wp-includes/js/prototype.js
+++ b/wp-includes/js/prototype.js
@@ -1,33 +1,19 @@
-/* Prototype JavaScript framework, version 1.5.1
+/* Prototype JavaScript framework, version 1.5.0
* (c) 2005-2007 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/
+ * For details, see the Prototype web site: http://prototype.conio.net/
*
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.5.1',
-
- Browser: {
- IE: !!(window.attachEvent && !window.opera),
- Opera: !!window.opera,
- WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
- Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
- },
-
+ Version: '1.5.0',
BrowserFeatures: {
- XPath: !!document.evaluate,
- ElementExtensions: !!window.HTMLElement,
- SpecificElementExtensions:
- (document.createElement('div').__proto__ !==
- document.createElement('form').__proto__)
+ XPath: !!document.evaluate
},
- ScriptFragment: '<script[^>]*>([\u0001-\uFFFF]*?)</script>',
- JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/,
-
- emptyFunction: function() { },
+ ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
+ emptyFunction: function() {},
K: function(x) { return x }
}
@@ -60,26 +46,6 @@ Object.extend(Object, {
}
},
- toJSON: function(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 (object.ownerDocument === document) return;
- var results = [];
- for (var property in object) {
- var value = Object.toJSON(object[property]);
- if (value !== undefined)
- results.push(property.toJSON() + ': ' + value);
- }
- return '{' + results.join(', ') + '}';
- },
-
keys: function(object) {
var keys = [];
for (var property in object)
@@ -109,13 +75,15 @@ Function.prototype.bind = function() {
Function.prototype.bindAsEventListener = function(object) {
var __method = this, args = $A(arguments), object = args.shift();
return function(event) {
- return __method.apply(object, [event || window.event].concat(args));
+ return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments)));
}
}
Object.extend(Number.prototype, {
toColorPart: function() {
- return this.toPaddedString(2, 16);
+ var digits = this.toString(16);
+ if (this < 16) return '0' + digits;
+ return digits;
},
succ: function() {
@@ -125,27 +93,9 @@ Object.extend(Number.prototype, {
times: function(iterator) {
$R(0, this, true).each(iterator);
return this;
- },
-
- toPaddedString: function(length, radix) {
- var string = this.toString(radix || 10);
- return '0'.times(length - string.length) + string;
- },
-
- toJSON: function() {
- return isFinite(this) ? this.toString() : 'null';
}
});
-Date.prototype.toJSON = function() {
- return '"' + this.getFullYear() + '-' +
- (this.getMonth() + 1).toPaddedString(2) + '-' +
- this.getDate().toPaddedString(2) + 'T' +
- this.getHours().toPaddedString(2) + ':' +
- this.getMinutes().toPaddedString(2) + ':' +
- this.getSeconds().toPaddedString(2) + '"';
-};
-
var Try = {
these: function() {
var returnValue;
@@ -195,19 +145,9 @@ PeriodicalExecuter.prototype = {
}
}
}
-Object.extend(String, {
- interpret: function(value) {
- return value == null ? '' : String(value);
- },
- specialChar: {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '\\': '\\\\'
- }
-});
+String.interpret = function(value){
+ return value == null ? '' : String(value);
+}
Object.extend(String.prototype, {
gsub: function(pattern, replacement) {
@@ -273,16 +213,17 @@ Object.extend(String.prototype, {
},
escapeHTML: function() {
- var self = arguments.callee;
- self.text.data = this;
- return self.div.innerHTML;
+ var div = document.createElement('div');
+ var text = document.createTextNode(this);
+ div.appendChild(text);
+ return div.innerHTML;
},
unescapeHTML: function() {
var div = document.createElement('div');
div.innerHTML = this.stripTags();
return div.childNodes[0] ? (div.childNodes.length > 1 ?
- $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
+ $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) :
div.childNodes[0].nodeValue) : '';
},
@@ -292,15 +233,15 @@ Object.extend(String.prototype, {
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);
+ var name = decodeURIComponent(pair[0]);
+ var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;
- if (key in hash) {
- if (hash[key].constructor != Array) hash[key] = [hash[key]];
- hash[key].push(value);
+ if (hash[name] !== undefined) {
+ if (hash[name].constructor != Array)
+ hash[name] = [hash[name]];
+ if (value) hash[name].push(value);
}
- else hash[key] = value;
+ else hash[name] = value;
}
return hash;
});
@@ -315,12 +256,6 @@ Object.extend(String.prototype, {
String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
},
- times: function(count) {
- var result = '';
- for (var i = 0; i < count; i++) result += this;
- return result;
- },
-
camelize: function() {
var parts = this.split('-'), len = parts.length;
if (len == 1) return parts[0];
@@ -335,7 +270,7 @@ Object.extend(String.prototype, {
return camelized;
},
- capitalize: function() {
+ capitalize: function(){
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
},
@@ -348,59 +283,11 @@ Object.extend(String.prototype, {
},
inspect: function(useDoubleQuotes) {
- var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
- var character = String.specialChar[match[0]];
- return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
- });
- if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
- return "'" + escapedString.replace(/'/g, '\\\'') + "'";
- },
-
- toJSON: function() {
- return this.inspect(true);
- },
-
- unfilterJSON: function(filter) {
- return this.sub(filter || Prototype.JSONFilter, '#{1}');
- },
-
- evalJSON: function(sanitize) {
- var json = this.unfilterJSON();
- try {
- if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json)))
- return eval('(' + json + ')');
- } catch (e) { }
- throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
- },
-
- include: function(pattern) {
- return this.indexOf(pattern) > -1;
- },
-
- startsWith: function(pattern) {
- return this.indexOf(pattern) === 0;
- },
-
- endsWith: function(pattern) {
- var d = this.length - pattern.length;
- return d >= 0 && this.lastIndexOf(pattern) === d;
- },
-
- empty: function() {
- return this == '';
- },
-
- blank: function() {
- return /^\s*$/.test(this);
- }
-});
-
-if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
- escapeHTML: function() {
- return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
- },
- unescapeHTML: function() {
- return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
+ var escapedString = this.replace(/\\/g, '\\\\');
+ if (useDoubleQuotes)
+ return '"' + escapedString.replace(/"/g, '\\"') + '"';
+ else
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
}
});
@@ -412,13 +299,6 @@ String.prototype.gsub.prepareReplacement = function(replacement) {
String.prototype.parseQuery = String.prototype.toQueryParams;
-Object.extend(String.prototype.escapeHTML, {
- div: document.createElement('div'),
- text: document.createTextNode('')
-});
-
-with (String.prototype.escapeHTML) div.appendChild(text);
-
var Template = Class.create();
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype = {
@@ -436,14 +316,19 @@ Template.prototype = {
}
}
-var $break = {}, $continue = new Error('"throw $continue" is deprecated, use "return" instead');
+var $break = new Object();
+var $continue = new Object();
var Enumerable = {
each: function(iterator) {
var index = 0;
try {
this._each(function(value) {
- iterator(value, index++);
+ try {
+ iterator(value, index++);
+ } catch (e) {
+ if (e != $continue) throw e;
+ }
});
} catch (e) {
if (e != $break) throw e;
@@ -645,21 +530,6 @@ var $A = Array.from = function(iterable) {
}
}
-if (Prototype.Browser.WebKit) {
- $A = Array.from = function(iterable) {
- if (!iterable) return [];
- if (!(typeof iterable == 'function' && iterable == '[object NodeList]') &&
- iterable.toArray) {
- return iterable.toArray();
- } else {
- var results = [];
- for (var i = 0, length = iterable.length; i < length; i++)
- results.push(iterable[i]);
- return results;
- }
- }
-}
-
Object.extend(Array.prototype, Enumerable);
if (!Array.prototype._reverse)
@@ -718,11 +588,9 @@ Object.extend(Array.prototype, {
return this.length > 1 ? this : this[0];
},
- uniq: function(sorted) {
- return this.inject([], function(array, value, index) {
- if (0 == index || (sorted ? array.last() != value : !array.include(value)))
- array.push(value);
- return array;
+ uniq: function() {
+ return this.inject([], function(array, value) {
+ return array.include(value) ? array : array.concat([value]);
});
},
@@ -736,32 +604,23 @@ Object.extend(Array.prototype, {
inspect: function() {
return '[' + this.map(Object.inspect).join(', ') + ']';
- },
-
- toJSON: function() {
- var results = [];
- this.each(function(object) {
- var value = Object.toJSON(object);
- if (value !== undefined) results.push(value);
- });
- return '[' + results.join(', ') + ']';
}
});
Array.prototype.toArray = Array.prototype.clone;
-function $w(string) {
+function $w(string){
string = string.strip();
return string ? string.split(/\s+/) : [];
}
-if (Prototype.Browser.Opera){
- Array.prototype.concat = function() {
+if(window.opera){
+ Array.prototype.concat = function(){
var array = [];
- for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
- for (var i = 0, length = arguments.length; i < length; i++) {
- if (arguments[i].constructor == Array) {
- for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
+ for(var i = 0, length = this.length; i < length; i++) array.push(this[i]);
+ for(var i = 0, length = arguments.length; i < length; i++) {
+ if(arguments[i].constructor == Array) {
+ for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
array.push(arguments[i][j]);
} else {
array.push(arguments[i]);
@@ -770,48 +629,37 @@ if (Prototype.Browser.Opera){
return array;
}
}
-var Hash = function(object) {
- if (object instanceof Hash) this.merge(object);
- else Object.extend(this, object || {});
+var Hash = function(obj) {
+ Object.extend(this, obj || {});
};
Object.extend(Hash, {
toQueryString: function(obj) {
var parts = [];
- parts.add = arguments.callee.addPair;
- this.prototype._each.call(obj, function(pair) {
+ this.prototype._each.call(obj, function(pair) {
if (!pair.key) return;
- var value = pair.value;
- if (value && typeof value == 'object') {
- if (value.constructor == Array) value.each(function(value) {
- parts.add(pair.key, value);
- });
- return;
+ if (pair.value && pair.value.constructor == Array) {
+ var values = pair.value.compact();
+ if (values.length < 2) pair.value = values.reduce();
+ else {
+ key = encodeURIComponent(pair.key);
+ values.each(function(value) {
+ value = value != undefined ? encodeURIComponent(value) : '';
+ parts.push(key + '=' + encodeURIComponent(value));
+ });
+ return;
+ }
}
- parts.add(pair.key, value);
- });
+ if (pair.value == undefined) pair[1] = '';
+ parts.push(pair.map(encodeURIComponent).join('='));
+ });
return parts.join('&');
- },
-
- toJSON: function(object) {
- var results = [];
- this.prototype._each.call(object, function(pair) {
- var value = Object.toJSON(pair.value);
- if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value);
- });
- return '{' + results.join(', ') + '}';
}
});
-Hash.toQueryString.addPair = function(key, value, prefix) {
- key = encodeURIComponent(key);
- if (value === undefined) this.push(key);
- else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));
-}
-
Object.extend(Hash.prototype, Enumerable);
Object.extend(Hash.prototype, {
_each: function(iterator) {
@@ -865,36 +713,13 @@ Object.extend(Hash.prototype, {
return '#<Hash:{' + this.map(function(pair) {
return pair.map(Object.inspect).join(': ');
}).join(', ') + '}>';
- },
-
- toJSON: function() {
- return Hash.toJSON(this);
}
});
function $H(object) {
- if (object instanceof Hash) return object;
+ if (object && object.constructor == Hash) return object;
return new Hash(object);
};
-
-// Safari iterates over shadowed properties
-if (function() {
- var i = 0, Test = function(value) { this.key = value };
- Test.prototype.key = 'foo';
- for (var property in new Test('bar')) i++;
- return i > 1;
-}()) Hash.prototype._each = function(iterator) {
- var cache = [];
- for (var key in this) {
- var value = this[key];
- if ((value && value == Hash.prototype[key]) || cache.include(key)) continue;
- cache.push(key);
- var pair = [key, value];
- pair.key = key;
- pair.value = value;
- iterator(pair);
- }
-};
ObjectRange = Class.create();
Object.extend(ObjectRange.prototype, Enumerable);
Object.extend(ObjectRange.prototype, {
@@ -1009,7 +834,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
request: function(url) {
this.url = url;
this.method = this.options.method;
- var params = Object.clone(this.options.parameters);
+ var params = this.options.parameters;
if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
@@ -1017,18 +842,14 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.method = 'post';
}
- this.parameters = params;
+ params = Hash.toQueryString(params);
+ if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='
- if (params = Hash.toQueryString(params)) {
- // when GET, append parameters to URL
- if (this.method == 'get')
- this.url += (this.url.include('?') ? '&' : '?') + params;
- else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
- params += '&_=';
- }
+ // when GET, append parameters to URL
+ if (this.method == 'get' && params)
+ this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params;
try {
- if (this.options.onCreate) this.options.onCreate(this.transport);
Ajax.Responders.dispatch('onCreate', this, this.transport);
this.transport.open(this.method.toUpperCase(), this.url,
@@ -1040,8 +861,9 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();
- this.body = this.method == 'post' ? (this.options.postBody || params) : null;
- this.transport.send(this.body);
+ var body = this.method == 'post' ? (this.options.postBody || params) : null;
+
+ this.transport.send(body);
/* Force Firefox to handle ready state 4 for synchronous requests */
if (!this.options.asynchronous && this.transport.overrideMimeType)
@@ -1113,8 +935,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.dispatchException(e);
}
- var contentType = this.getHeader('Content-type');
- if (contentType && contentType.strip().
+ if ((this.getHeader('Content-type') || 'text/javascript').strip().
match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
this.evalResponse();
}
@@ -1141,13 +962,13 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
evalJSON: function() {
try {
var json = this.getHeader('X-JSON');
- return json ? json.evalJSON() : null;
+ return json ? eval('(' + json + ')') : null;
} catch (e) { return null }
},
evalResponse: function() {
try {
- return eval((this.transport.responseText || '').unfilterJSON());
+ return eval(this.transport.responseText);
} catch (e) {
this.dispatchException(e);
}
@@ -1262,52 +1083,50 @@ if (Prototype.BrowserFeatures.XPath) {
results.push(query.snapshotItem(i));
return results;
};
+}
- document.getElementsByClassName = function(className, parentElement) {
+document.getElementsByClassName = function(className, parentElement) {
+ if (Prototype.BrowserFeatures.XPath) {
var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
return document._getElementsByXPath(q, parentElement);
+ } else {
+ var children = ($(parentElement) || document.body).getElementsByTagName('*');
+ var elements = [], child;
+ for (var i = 0, length = children.length; i < length; i++) {
+ child = children[i];
+ if (Element.hasClassName(child, className))
+ elements.push(Element.extend(child));
+ }
+ return elements;
}
-
-} else document.getElementsByClassName = function(className, parentElement) {
- var children = ($(parentElement) || document.body).getElementsByTagName('*');
- var elements = [], child;
- for (var i = 0, length = children.length; i < length; i++) {
- child = children[i];
- if (Element.hasClassName(child, className))
- elements.push(Element.extend(child));
- }
- return elements;
};
/*--------------------------------------------------------------------------*/
-if (!window.Element) var Element = {};
+if (!window.Element)
+ var Element = new Object();
Element.extend = function(element) {
- var F = Prototype.BrowserFeatures;
- if (!element || !element.tagName || element.nodeType == 3 ||
- element._extended || F.SpecificElementExtensions || element == window)
- return element;
+ if (!element || _nativeExtensions || element.nodeType == 3) return element;
- var methods = {}, tagName = element.tagName, cache = Element.extend.cache,
- T = Element.Methods.ByTag;
+ if (!element._extended && element.tagName && element != window) {
+ var methods = Object.clone(Element.Methods), cache = Element.extend.cache;
- // extend methods for all tags (Safari doesn't need this)
- if (!F.ElementExtensions) {
- Object.extend(methods, Element.Methods),
- Object.extend(methods, Element.Methods.Simulated);
- }
+ if (element.tagName == 'FORM')
+ Object.extend(methods, Form.Methods);
+ if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName))
+ Object.extend(methods, Form.Element.Methods);
- // extend methods for specific tags
- if (T[tagName]) Object.extend(methods, T[tagName]);
+ Object.extend(methods, Element.Methods.Simulated);
- for (var property in methods) {
- var value = methods[property];
- if (typeof value == 'function' && !(property in element))
- element[property] = cache.findOrStore(value);
+ for (var property in methods) {
+ var value = methods[property];
+ if (typeof value == 'function' && !(property in element))
+ element[property] = cache.findOrStore(value);
+ }
}
- element._extended = Prototype.emptyFunction;
+ element._extended = true;
return element;
};
@@ -1393,13 +1212,7 @@ Element.Methods = {
},
descendants: function(element) {
- return $A($(element).getElementsByTagName('*')).each(Element.extend);
- },
-
- firstDescendant: function(element) {
- element = $(element).firstChild;
- while (element && element.nodeType != 1) element = element.nextSibling;
- return $(element);
+ return $A($(element).getElementsByTagName('*'));
},
immediateDescendants: function(element) {
@@ -1429,35 +1242,19 @@ Element.Methods = {
},
up: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return $(element.parentNode);
- var ancestors = element.ancestors();
- return expression ? Selector.findElement(ancestors, expression, index) :
- ancestors[index || 0];
+ return Selector.findElement($(element).ancestors(), expression, index);
},
down: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return element.firstDescendant();
- var descendants = element.descendants();
- return expression ? Selector.findElement(descendants, expression, index) :
- descendants[index || 0];
+ return Selector.findElement($(element).descendants(), expression, index);
},
previous: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
- var previousSiblings = element.previousSiblings();
- return expression ? Selector.findElement(previousSiblings, expression, index) :
- previousSiblings[index || 0];
+ return Selector.findElement($(element).previousSiblings(), expression, index);
},
next: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
- var nextSiblings = element.nextSiblings();
- return expression ? Selector.findElement(nextSiblings, expression, index) :
- nextSiblings[index || 0];
+ return Selector.findElement($(element).nextSiblings(), expression, index);
},
getElementsBySelector: function() {
@@ -1471,13 +1268,12 @@ Element.Methods = {
readAttribute: function(element, name) {
element = $(element);
- if (Prototype.Browser.IE) {
- if (!element.attributes) return null;
+ if (document.all && !window.opera) {
var t = Element._attributeTranslations;
if (t.values[name]) return t.values[name](element, name);
if (t.names[name]) name = t.names[name];
var attribute = element.attributes[name];
- return attribute ? attribute.nodeValue : null;
+ if(attribute) return attribute.nodeValue;
}
return element.getAttribute(name);
},
@@ -1546,7 +1342,7 @@ Element.Methods = {
},
empty: function(element) {
- return $(element).innerHTML.blank();
+ return $(element).innerHTML.match(/^\s*$/);
},
descendantOf: function(element, ancestor) {
@@ -1565,38 +1361,55 @@ Element.Methods = {
getStyle: function(element, style) {
element = $(element);
- style = style == 'float' ? 'cssFloat' : style.camelize();
+ if (['float','cssFloat'].include(style))
+ style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat');
+ style = style.camelize();
var value = element.style[style];
if (!value) {
- var css = document.defaultView.getComputedStyle(element, null);
- value = css ? css[style] : null;
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+ var css = document.defaultView.getComputedStyle(element, null);
+ value = css ? css[style] : null;
+ } else if (element.currentStyle) {
+ value = element.currentStyle[style];
+ }
}
- 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, camelized) {
- element = $(element);
- var elementStyle = element.style;
-
- for (var property in styles)
- if (property == 'opacity') element.setOpacity(styles[property])
- else
- elementStyle[(property == 'float' || property == 'cssFloat') ?
- (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') :
- (camelized ? property : property.camelize())] = styles[property];
+ if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none'))
+ value = element['offset'+style.capitalize()] + 'px';
- return element;
+ if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
+ if (Element.getStyle(element, 'position') == 'static') value = 'auto';
+ if(style == 'opacity') {
+ if(value) return parseFloat(value);
+ if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
+ if(value[1]) return parseFloat(value[1]) / 100;
+ return 1.0;
+ }
+ return value == 'auto' ? null : value;
},
- setOpacity: function(element, value) {
+ setStyle: function(element, style) {
element = $(element);
- element.style.opacity = (value == 1 || value === '') ? '' :
- (value < 0.00001) ? 0 : value;
+ for (var name in style) {
+ var value = style[name];
+ if(name == 'opacity') {
+ if (value == 1) {
+ value = (/Gecko/.test(navigator.userAgent) &&
+ !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0;
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
+ } else if(value == '') {
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
+ } else {
+ if(value < 0.00001) value = 0;
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
+ 'alpha(opacity='+value*100+')';
+ }
+ } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat';
+ element.style[name.camelize()] = value;
+ }
return element;
},
@@ -1670,58 +1483,61 @@ Element.Methods = {
}
};
-Object.extend(Element.Methods, {
- childOf: Element.Methods.descendantOf,
- childElements: Element.Methods.immediateDescendants
-});
+Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf});
+
+Element._attributeTranslations = {};
+
+Element._attributeTranslations.names = {
+ colspan: "colSpan",
+ rowspan: "rowSpan",
+ valign: "vAlign",
+ datetime: "dateTime",
+ accesskey: "accessKey",
+ tabindex: "tabIndex",
+ enctype: "encType",
+ maxlength: "maxLength",
+ readonly: "readOnly",
+ longdesc: "longDesc"
+};
-if (Prototype.Browser.Opera) {
- Element.Methods._getStyle = Element.Methods.getStyle;
- Element.Methods.getStyle = function(element, style) {
- switch(style) {
- case 'left':
- case 'top':
- case 'right':
- case 'bottom':
- if (Element._getStyle(element, 'position') == 'static') return null;
- default: return Element._getStyle(element, style);
- }
- };
-}
-else if (Prototype.Browser.IE) {
- 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];
+Element._attributeTranslations.values = {
+ _getAttr: function(element, attribute) {
+ return element.getAttribute(attribute, 2);
+ },
- if (style == 'opacity') {
- if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
- if (value[1]) return parseFloat(value[1]) / 100;
- return 1.0;
- }
+ _flag: function(element, attribute) {
+ return $(element).hasAttribute(attribute) ? attribute : null;
+ },
- if (value == 'auto') {
- if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
- return element['offset'+style.capitalize()] + 'px';
- return null;
- }
- return value;
- };
+ style: function(element) {
+ return element.style.cssText.toLowerCase();
+ },
- Element.Methods.setOpacity = function(element, value) {
- element = $(element);
- var filter = element.getStyle('filter'), style = element.style;
- if (value == 1 || value === '') {
- style.filter = filter.replace(/alpha\([^\)]*\)/gi,'');
- return element;
- } else if (value < 0.00001) value = 0;
- style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') +
- 'alpha(opacity=' + (value * 100) + ')';
- return element;
- };
+ title: function(element) {
+ var node = element.getAttributeNode('title');
+ return node.specified ? node.nodeValue : null;
+ }
+};
- // IE is missing .innerHTML support for TABLE-related elements
+Object.extend(Element._attributeTranslations.values, {
+ href: Element._attributeTranslations.values._getAttr,
+ src: Element._attributeTranslations.values._getAttr,
+ disabled: Element._attributeTranslations.values._flag,
+ checked: Element._attributeTranslations.values._flag,
+ readonly: Element._attributeTranslations.values._flag,
+ multiple: Element._attributeTranslations.values._flag
+});
+
+Element.Methods.Simulated = {
+ hasAttribute: function(element, attribute) {
+ var t = Element._attributeTranslations;
+ attribute = t.names[attribute] || attribute;
+ return $(element).getAttributeNode(attribute).specified;
+ }
+};
+
+// IE is missing .innerHTML support for TABLE-related elements
+if (document.all && !window.opera){
Element.Methods.update = function(element, html) {
element = $(element);
html = typeof html == 'undefined' ? '' : html.toString();
@@ -1742,123 +1558,35 @@ else if (Prototype.Browser.IE) {
div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>';
depth = 4;
}
- $A(element.childNodes).each(function(node) { element.removeChild(node) });
- depth.times(function() { div = div.firstChild });
- $A(div.childNodes).each(function(node) { element.appendChild(node) });
+ $A(element.childNodes).each(function(node){
+ element.removeChild(node)
+ });
+ depth.times(function(){ div = div.firstChild });
+
+ $A(div.childNodes).each(
+ function(node){ element.appendChild(node) });
} else {
element.innerHTML = html.stripScripts();
}
- setTimeout(function() { html.evalScripts() }, 10);
- return element;
- }
-}
-else if (Prototype.Browser.Gecko) {
- Element.Methods.setOpacity = function(element, value) {
- element = $(element);
- element.style.opacity = (value == 1) ? 0.999999 :
- (value === '') ? '' : (value < 0.00001) ? 0 : value;
+ setTimeout(function() {html.evalScripts()}, 10);
return element;
- };
-}
-
-Element._attributeTranslations = {
- names: {
- colspan: "colSpan",
- rowspan: "rowSpan",
- valign: "vAlign",
- datetime: "dateTime",
- accesskey: "accessKey",
- tabindex: "tabIndex",
- enctype: "encType",
- maxlength: "maxLength",
- readonly: "readOnly",
- longdesc: "longDesc"
- },
- values: {
- _getAttr: function(element, attribute) {
- return element.getAttribute(attribute, 2);
- },
- _flag: function(element, attribute) {
- return $(element).hasAttribute(attribute) ? attribute : null;
- },
- style: function(element) {
- return element.style.cssText.toLowerCase();
- },
- title: function(element) {
- var node = element.getAttributeNode('title');
- return node.specified ? node.nodeValue : null;
- }
}
};
-(function() {
- Object.extend(this, {
- href: this._getAttr,
- src: this._getAttr,
- type: this._getAttr,
- disabled: this._flag,
- checked: this._flag,
- readonly: this._flag,
- multiple: this._flag
- });
-}).call(Element._attributeTranslations.values);
-
-Element.Methods.Simulated = {
- hasAttribute: function(element, attribute) {
- var t = Element._attributeTranslations, node;
- attribute = t.names[attribute] || attribute;
- node = $(element).getAttributeNode(attribute);
- return node && node.specified;
- }
-};
-
-Element.Methods.ByTag = {};
-
Object.extend(Element, Element.Methods);
-if (!Prototype.BrowserFeatures.ElementExtensions &&
- document.createElement('div').__proto__) {
- window.HTMLElement = {};
- window.HTMLElement.prototype = document.createElement('div').__proto__;
- Prototype.BrowserFeatures.ElementExtensions = true;
-}
+var _nativeExtensions = false;
-Element.hasAttribute = function(element, attribute) {
- if (element.hasAttribute) return element.hasAttribute(attribute);
- return Element.Methods.Simulated.hasAttribute(element, attribute);
-};
+if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))
+ ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) {
+ var className = 'HTML' + tag + 'Element';
+ if(window[className]) return;
+ var klass = window[className] = {};
+ klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__;
+ });
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 (tagName.constructor == Array) 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);
- }
+ Object.extend(Element.Methods, methods || {});
function copy(methods, destination, onlyIfAbsent) {
onlyIfAbsent = onlyIfAbsent || false;
@@ -1870,49 +1598,19 @@ Element.addMethods = function(methods) {
}
}
- 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];
-
- window[klass] = {};
- window[klass].prototype = document.createElement(tagName).__proto__;
- return window[klass];
- }
-
- if (F.ElementExtensions) {
+ if (typeof HTMLElement != 'undefined') {
copy(Element.Methods, HTMLElement.prototype);
copy(Element.Methods.Simulated, HTMLElement.prototype, true);
+ copy(Form.Methods, HTMLFormElement.prototype);
+ [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) {
+ copy(Form.Element.Methods, klass.prototype);
+ });
+ _nativeExtensions = true;
}
+}
- if (F.SpecificElementExtensions) {
- for (var tag in Element.Methods.ByTag) {
- var klass = findDOMClass(tag);
- if (typeof klass == "undefined") continue;
- copy(T[tag], klass.prototype);
- }
- }
-
- Object.extend(Element, Element.Methods);
- delete Element.ByTag;
-};
-
-var Toggle = { display: Element.toggle };
+var Toggle = new Object();
+Toggle.display = Element.toggle;
/*--------------------------------------------------------------------------*/
@@ -2043,572 +1741,129 @@ Element.ClassNames.prototype = {
};
Object.extend(Element.ClassNames.prototype, Enumerable);
-/* 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();
-
Selector.prototype = {
initialize: function(expression) {
- this.expression = expression.strip();
+ this.params = {classNames: []};
+ this.expression = expression.toString().strip();
+ this.parseExpression();
this.compileMatcher();
},
- compileMatcher: function() {
- // Selectors with namespaced attributes can't use the XPath version
- if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression))
- return this.compileXPathMatcher();
+ parseExpression: function() {
+ function abort(message) { throw 'Parse error in selector: ' + message; }
- var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
- c = Selector.criteria, le, p, m;
+ if (this.expression == '') abort('empty expression');
- if (Selector._cache[e]) {
- this.matcher = Selector._cache[e]; return;
+ var params = this.params, expr = this.expression, match, modifier, clause, rest;
+ while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
+ params.attributes = params.attributes || [];
+ params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
+ expr = match[1];
}
- 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 in ps) {
- p = ps[i];
- if (m = e.match(p)) {
- this.matcher.push(typeof c[i] == 'function' ? c[i](m) :
- new Template(c[i]).evaluate(m));
- e = e.replace(m[0], '');
- break;
- }
+
+ if (expr == '*') return this.params.wildcard = true;
+
+ while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
+ modifier = match[1], clause = match[2], rest = match[3];
+ switch (modifier) {
+ case '#': params.id = clause; break;
+ case '.': params.classNames.push(clause); break;
+ case '':
+ case undefined: params.tagName = clause.toUpperCase(); break;
+ default: abort(expr.inspect());
}
+ expr = rest;
}
- this.matcher.push("return h.unique(n);\n}");
- eval(this.matcher.join('\n'));
- Selector._cache[this.expression] = this.matcher;
+ if (expr.length > 0) abort(expr.inspect());
},
- compileXPathMatcher: function() {
- var e = this.expression, ps = Selector.patterns,
- x = Selector.xpath, le, m;
+ buildMatchExpression: function() {
+ var params = this.params, conditions = [], clause;
- if (Selector._cache[e]) {
- this.xpath = Selector._cache[e]; return;
- }
+ if (params.wildcard)
+ conditions.push('true');
+ if (clause = params.id)
+ conditions.push('element.readAttribute("id") == ' + clause.inspect());
+ if (clause = params.tagName)
+ conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
+ if ((clause = params.classNames).length > 0)
+ for (var i = 0, length = clause.length; i < length; i++)
+ conditions.push('element.hasClassName(' + clause[i].inspect() + ')');
+ if (clause = params.attributes) {
+ clause.each(function(attribute) {
+ var value = 'element.readAttribute(' + attribute.name.inspect() + ')';
+ var splitValueBy = function(delimiter) {
+ return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
+ }
- this.matcher = ['.//*'];
- while (e && le != e && (/\S/).test(e)) {
- le = e;
- for (var i in ps) {
- if (m = e.match(ps[i])) {
- this.matcher.push(typeof x[i] == 'function' ? x[i](m) :
- new Template(x[i]).evaluate(m));
- e = e.replace(m[0], '');
- break;
+ switch (attribute.operator) {
+ case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
+ case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
+ case '|=': conditions.push(
+ splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
+ ); break;
+ case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
+ case '':
+ case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break;
+ default: throw 'Unknown operator ' + attribute.operator + ' in selector';
}
- }
+ });
}
- this.xpath = this.matcher.join('');
- Selector._cache[this.expression] = this.xpath;
- },
-
- findElements: function(root) {
- root = root || document;
- if (this.xpath) return document._getElementsByXPath(this.xpath, root);
- return this.matcher(root);
- },
-
- match: function(element) {
- return this.findElements(document).include(element);
+ return conditions.join(' && ');
},
- toString: function() {
- return this.expression;
+ compileMatcher: function() {
+ this.match = new Function('element', 'if (!element.tagName) return false; \
+ element = $(element); \
+ return ' + this.buildMatchExpression());
},
- inspect: function() {
- return "#<Selector:" + this.expression.inspect() + ">";
- }
-};
+ findElements: function(scope) {
+ var element;
-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: "[@#{1}]",
- attr: function(m) {
- 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 (typeof h === 'function') 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 or translate(text(), ' \t\r\n', '') = '')]",
- 'checked': "[@checked]",
- 'disabled': "[@disabled]",
- 'enabled': "[not(@disabled)]",
- 'not': function(m) {
- var e = m[6], p = Selector.patterns,
- x = Selector.xpath, le, m, v;
-
- var exclusion = [];
- while (e && le != e && (/\S/).test(e)) {
- le = e;
- for (var i in p) {
- if (m = e.match(p[i])) {
- v = typeof x[i] == 'function' ? x[i](m) : new Template(x[i]).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 });
- }
- }
- }
- },
+ if (element = $(this.params.id))
+ if (this.match(element))
+ if (!scope || Element.childOf(element, scope))
+ return [element];
- 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 = false;',
- attr: function(m) {
- m[3] = (m[5] || m[6]);
- return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); 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: {
- // combinators must be listed first
- // (and descendant needs to be last combinator)
- laterSibling: /^\s*~\s*/,
- child: /^\s*>\s*/,
- adjacent: /^\s*\+\s*/,
- descendant: /^\s/,
-
- // selectors follow
- tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
- id: /^#([\w\-\*]+)(\b|$)/,
- className: /^\.([\w\-\*]+)(\b|$)/,
- pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,
- attrPresence: /^\[([\w]+)\]/,
- attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/
- },
-
- handlers: {
- // UTILITY FUNCTIONS
- // joins two collections
- concat: function(a, b) {
- for (var i = 0, node; node = b[i]; i++)
- a.push(node);
- return a;
- },
-
- // marks an array of nodes for counting
- mark: function(nodes) {
- for (var i = 0, node; node = nodes[i]; i++)
- node._counted = true;
- return nodes;
- },
-
- unmark: function(nodes) {
- for (var i = 0, node; node = nodes[i]; i++)
- node._counted = undefined;
- return nodes;
- },
-
- // mark each child node with its position (for nth calls)
- // "ofType" flag indicates whether we're indexing for nth-of-type
- // rather than nth-child
- index: function(parentNode, reverse, ofType) {
- parentNode._counted = true;
- if (reverse) {
- for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
- node = nodes[i];
- if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
- }
- } else {
- for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
- if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
- }
- },
-
- // filters out duplicates and extends all nodes
- unique: function(nodes) {
- if (nodes.length == 0) return nodes;
- var results = [], n;
- for (var i = 0, l = nodes.length; i < l; i++)
- if (!(n = nodes[i])._counted) {
- n._counted = true;
- results.push(Element.extend(n));
- }
- return Selector.handlers.unmark(results);
- },
-
- // COMBINATOR FUNCTIONS
- 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, children = [], 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;
- },
-
- // TOKEN FUNCTIONS
- tagName: function(nodes, root, tagName, combinator) {
- tagName = tagName.toUpperCase();
- var results = [], h = Selector.handlers;
- if (nodes) {
- if (combinator) {
- // fastlane for ordinary descendant combinators
- 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() == tagName) results.push(node);
- return results;
- } else return root.getElementsByTagName(tagName);
- },
-
- id: function(nodes, root, id, combinator) {
- var targetNode = $(id), h = Selector.handlers;
- if (!nodes && root == document) return targetNode ? [targetNode] : [];
- 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) {
- 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) {
- if (!nodes) nodes = root.getElementsByTagName("*");
- 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;
- },
+ scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
- 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);
- }
- },
+ var results = [];
+ for (var i = 0, length = scope.length; i < length; i++)
+ if (this.match(element = scope[i]))
+ results.push(Element.extend(element));
- 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);
- },
-
- // handles the an+b logic
- 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;
- });
- },
-
- // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
- 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._counted) {
- 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++) {
- // IE treats comments as element nodes
- if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) 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._counted) 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) 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;
- }
+ return results;
},
- operators: {
- '=': function(nv, v) { return nv == v; },
- '!=': function(nv, v) { return nv != v; },
- '^=': function(nv, v) { return nv.startsWith(v); },
- '$=': function(nv, v) { return nv.endsWith(v); },
- '*=': function(nv, v) { return nv.include(v); },
- '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
- '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
- },
+ toString: function() {
+ return this.expression;
+ }
+}
+Object.extend(Selector, {
matchElements: function(elements, expression) {
- var matches = new Selector(expression).findElements(), h = Selector.handlers;
- h.mark(matches);
- for (var i = 0, results = [], element; element = elements[i]; i++)
- if (element._counted) results.push(element);
- h.unmark(matches);
- return results;
+ var selector = new Selector(expression);
+ return elements.select(selector.match.bind(selector)).map(Element.extend);
},
findElement: function(elements, expression, index) {
- if (typeof expression == 'number') {
- index = expression; expression = false;
- }
+ if (typeof expression == 'number') index = expression, expression = false;
return Selector.matchElements(elements, expression || '*')[index || 0];
},
findChildElements: function(element, expressions) {
- var exprs = expressions.join(','), expressions = [];
- exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
- expressions.push(m[1].strip());
- });
- 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;
+ return expressions.map(function(expression) {
+ return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) {
+ var selector = new Selector(expr);
+ return results.inject([], function(elements, result) {
+ return elements.concat(selector.findElements(result || element));
+ });
+ });
+ }).flatten();
}
});
@@ -2625,8 +1880,8 @@ var Form = {
var data = elements.inject({}, function(result, element) {
if (!element.disabled && element.name) {
var key = element.name, value = $(element).getValue();
- if (value != null) {
- if (key in result) {
+ if (value != undefined) {
+ if (result[key]) {
if (result[key].constructor != Array) result[key] = [result[key]];
result[key].push(value);
}
@@ -2673,13 +1928,18 @@ Form.Methods = {
disable: function(form) {
form = $(form);
- Form.getElements(form).invoke('disable');
+ form.getElements().each(function(element) {
+ element.blur();
+ element.disabled = 'true';
+ });
return form;
},
enable: function(form) {
form = $(form);
- Form.getElements(form).invoke('enable');
+ form.getElements().each(function(element) {
+ element.disabled = '';
+ });
return form;
},
@@ -2694,26 +1954,11 @@ Form.Methods = {
form = $(form);
form.findFirstElement().activate();
return form;
- },
-
- request: function(form, options) {
- form = $(form), options = Object.clone(options || {});
-
- var params = options.parameters;
- options.parameters = form.serialize(true);
-
- if (params) {
- if (typeof params == 'string') params = params.toQueryParams();
- Object.extend(options.parameters, params);
- }
-
- if (form.hasAttribute('method') && !options.method)
- options.method = form.method;
-
- return new Ajax.Request(form.readAttribute('action'), options);
}
}
+Object.extend(Form, Form.Methods);
+
/*--------------------------------------------------------------------------*/
Form.Element = {
@@ -2759,33 +2004,30 @@ Form.Element.Methods = {
activate: function(element) {
element = $(element);
- try {
- element.focus();
- if (element.select && (element.tagName.toLowerCase() != 'input' ||
- !['button', 'reset', 'submit'].include(element.type)))
- element.select();
- } catch (e) {}
+ element.focus();
+ if (element.select && ( element.tagName.toLowerCase() != 'input' ||
+ !['button', 'reset', 'submit'].include(element.type) ) )
+ element.select();
return element;
},
disable: function(element) {
element = $(element);
- element.blur();
element.disabled = true;
return element;
},
enable: function(element) {
element = $(element);
+ element.blur();
element.disabled = false;
return element;
}
}
-/*--------------------------------------------------------------------------*/
-
+Object.extend(Form.Element, Form.Element.Methods);
var Field = Form.Element;
-var $F = Form.Element.Methods.getValue;
+var $F = Form.Element.getValue;
/*--------------------------------------------------------------------------*/
@@ -2952,7 +2194,7 @@ Object.extend(Event, {
KEY_PAGEDOWN: 34,
element: function(event) {
- return $(event.target || event.srcElement);
+ return event.target || event.srcElement;
},
isLeftClick: function(event) {
@@ -3017,7 +2259,8 @@ Object.extend(Event, {
useCapture = useCapture || false;
if (name == 'keypress' &&
- (Prototype.Browser.WebKit || element.attachEvent))
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+ || element.attachEvent))
name = 'keydown';
Event._observeAndCache(element, name, observer, useCapture);
@@ -3028,7 +2271,8 @@ Object.extend(Event, {
useCapture = useCapture || false;
if (name == 'keypress' &&
- (Prototype.Browser.WebKit || element.attachEvent))
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+ || element.detachEvent))
name = 'keydown';
if (element.removeEventListener) {
@@ -3042,7 +2286,7 @@ Object.extend(Event, {
});
/* prevent memory leaks in IE */
-if (Prototype.Browser.IE)
+if (navigator.appVersion.match(/\bMSIE\b/))
Event.observe(window, 'unload', Event.unloadCache, false);
var Position = {
// set to true if needed, warning: firefox performance problems
@@ -3156,7 +2400,7 @@ var Position = {
valueL += element.offsetLeft || 0;
// Safari fix
- if (element.offsetParent == document.body)
+ if (element.offsetParent==document.body)
if (Element.getStyle(element,'position')=='absolute') break;
} while (element = element.offsetParent);
@@ -3252,7 +2496,7 @@ var Position = {
// Safari returns margins on body which is incorrect if the child is absolutely
// positioned. For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
-if (Prototype.Browser.WebKit) {
+if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
Position.cumulativeOffset = function(element) {
var valueT = 0, valueL = 0;
do {
diff --git a/wp-includes/js/scriptaculous/builder.js b/wp-includes/js/scriptaculous/builder.js
index 69a1506..199afc1 100644
--- a/wp-includes/js/scriptaculous/builder.js
+++ b/wp-includes/js/scriptaculous/builder.js
@@ -1,6 +1,6 @@
-// script.aculo.us builder.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005, 2006 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/
@@ -48,8 +48,7 @@ var Builder = {
// attributes (or text)
if(arguments[1])
if(this._isStringOrNumber(arguments[1]) ||
- (arguments[1] instanceof Array) ||
- arguments[1].tagName) {
+ (arguments[1] instanceof Array)) {
this._children(element, arguments[1]);
} else {
var attrs = this._attributes(arguments[1]);
@@ -67,7 +66,7 @@ var Builder = {
}
if(element.tagName.toUpperCase() != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
- }
+ }
}
// text, or array of children
@@ -93,10 +92,6 @@ var Builder = {
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')
@@ -106,8 +101,8 @@ var Builder = {
element.appendChild(Builder._text(e));
});
} else
- if(Builder._isStringOrNumber(children))
- element.appendChild(Builder._text(children));
+ if(Builder._isStringOrNumber(children))
+ element.appendChild(Builder._text(children));
},
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
diff --git a/wp-includes/js/scriptaculous/controls.js b/wp-includes/js/scriptaculous/controls.js
index feea27e..46f2cc1 100644
--- a/wp-includes/js/scriptaculous/controls.js
+++ b/wp-includes/js/scriptaculous/controls.js
@@ -1,8 +1,8 @@
-// script.aculo.us controls.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+// script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
+// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
@@ -43,8 +43,7 @@ var Autocompleter = {}
Autocompleter.Base = function() {};
Autocompleter.Base.prototype = {
baseInitialize: function(element, update, options) {
- element = $(element)
- this.element = element;
+ this.element = $(element);
this.update = $(update);
this.hasFocus = false;
this.changed = false;
@@ -84,20 +83,15 @@ Autocompleter.Base.prototype = {
Element.hide(this.update);
- Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
- Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this));
-
- // Turn autocomplete back on when the user leaves the page, so that the
- // field's value will be remembered on Mozilla-based browsers.
- Event.observe(window, 'beforeunload', function(){
- element.setAttribute('autocomplete', 'on');
- });
+ Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, "keypress", 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) &&
+ (navigator.appVersion.indexOf('MSIE')>0) &&
+ (navigator.userAgent.indexOf('Opera')<0) &&
(Element.getStyle(this.update, 'position')=='absolute')) {
new Insertion.After(this.update,
'<iframe id="' + this.update.id + '_iefix" '+
@@ -147,17 +141,17 @@ Autocompleter.Base.prototype = {
case Event.KEY_UP:
this.markPrevious();
this.render();
- if(Prototype.Browser.WebKit) Event.stop(event);
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
return;
case Event.KEY_DOWN:
this.markNext();
this.render();
- if(Prototype.Browser.WebKit) Event.stop(event);
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
return;
}
else
if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
- (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
+ (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
@@ -203,6 +197,7 @@ Autocompleter.Base.prototype = {
this.index==i ?
Element.addClassName(this.getEntry(i),"selected") :
Element.removeClassName(this.getEntry(i),"selected");
+
if(this.hasFocus) {
this.show();
this.active = true;
@@ -304,6 +299,7 @@ Autocompleter.Base.prototype = {
onObserverEvent: function() {
this.changed = false;
if(this.getToken().length>=this.options.minChars) {
+ this.startIndicator();
this.getUpdatedChoices();
} else {
this.active = false;
@@ -344,9 +340,7 @@ Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.pro
},
getUpdatedChoices: function() {
- this.startIndicator();
-
- var entry = encodeURIComponent(this.options.paramName) + '=' +
+ entry = encodeURIComponent(this.options.paramName) + '=' +
encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ?
@@ -354,7 +348,7 @@ Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.pro
if(this.options.defaultParams)
this.options.parameters += '&' + this.options.defaultParams;
-
+
new Ajax.Request(this.url, this.options);
},
@@ -483,14 +477,9 @@ Ajax.InPlaceEditor.prototype = {
this.options = Object.extend({
paramName: "value",
okButton: true,
- okLink: false,
okText: "ok",
- cancelButton: false,
cancelLink: true,
cancelText: "cancel",
- textBeforeControls: '',
- textBetweenControls: '',
- textAfterControls: '',
savingText: "Saving...",
clickToEditText: "Click to edit",
okText: "ok",
@@ -578,52 +567,23 @@ Ajax.InPlaceEditor.prototype = {
var br = document.createElement("br");
this.form.appendChild(br);
}
-
- if (this.options.textBeforeControls)
- this.form.appendChild(document.createTextNode(this.options.textBeforeControls));
if (this.options.okButton) {
- var okButton = document.createElement("input");
+ okButton = document.createElement("input");
okButton.type = "submit";
okButton.value = this.options.okText;
okButton.className = 'editor_ok_button';
this.form.appendChild(okButton);
}
-
- if (this.options.okLink) {
- var okLink = document.createElement("a");
- okLink.href = "#";
- okLink.appendChild(document.createTextNode(this.options.okText));
- okLink.onclick = this.onSubmit.bind(this);
- okLink.className = 'editor_ok_link';
- this.form.appendChild(okLink);
- }
-
- if (this.options.textBetweenControls &&
- (this.options.okLink || this.options.okButton) &&
- (this.options.cancelLink || this.options.cancelButton))
- this.form.appendChild(document.createTextNode(this.options.textBetweenControls));
-
- if (this.options.cancelButton) {
- var cancelButton = document.createElement("input");
- cancelButton.type = "submit";
- cancelButton.value = this.options.cancelText;
- cancelButton.onclick = this.onclickCancel.bind(this);
- cancelButton.className = 'editor_cancel_button';
- this.form.appendChild(cancelButton);
- }
if (this.options.cancelLink) {
- var cancelLink = document.createElement("a");
+ cancelLink = document.createElement("a");
cancelLink.href = "#";
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
cancelLink.onclick = this.onclickCancel.bind(this);
- cancelLink.className = 'editor_cancel editor_cancel_link';
+ cancelLink.className = 'editor_cancel';
this.form.appendChild(cancelLink);
}
-
- if (this.options.textAfterControls)
- this.form.appendChild(document.createTextNode(this.options.textAfterControls));
},
hasHTMLLineBreaks: function(string) {
if (!this.options.handleLineBreaks) return false;
diff --git a/wp-includes/js/scriptaculous/dragdrop.js b/wp-includes/js/scriptaculous/dragdrop.js
index 58fe342..32c91bc 100644
--- a/wp-includes/js/scriptaculous/dragdrop.js
+++ b/wp-includes/js/scriptaculous/dragdrop.js
@@ -1,7 +1,7 @@
-// script.aculo.us dragdrop.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+// script.aculo.us dragdrop.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
+// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
//
// 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/
@@ -112,10 +112,8 @@ var Droppables = {
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;
- }
+ if (this.last_active.onDrop)
+ this.last_active.onDrop(element, this.last_active.element, event);
},
reset: function() {
@@ -247,7 +245,6 @@ Draggable.prototype = {
},
zindex: 1000,
revert: false,
- quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
@@ -356,12 +353,8 @@ Draggable.prototype = {
updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event);
-
- if(!this.options.quiet){
- Position.prepare();
- Droppables.show(pointer, this.element);
- }
-
+ Position.prepare();
+ Droppables.show(pointer, this.element);
Draggables.notify('onDrag', this, event);
this.draw(pointer);
@@ -389,19 +382,13 @@ Draggable.prototype = {
}
// fix AppleWebKit rendering
- if(Prototype.Browser.WebKit) window.scrollBy(0,0);
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) 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) {
Position.relativize(this.element);
@@ -409,12 +396,7 @@ Draggable.prototype = {
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);
+ if(success) Droppables.fire(event, this.element);
Draggables.notify('onEnd', this, event);
var revert = this.options.revert;
@@ -422,9 +404,8 @@ Draggable.prototype = {
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]);
+ this.options.reverteffect(this.element,
+ d[1]-this.delta[1], d[0]-this.delta[0]);
} else {
this.delta = d;
}
@@ -633,7 +614,6 @@ var Sortable = {
delay: 0,
hoverclass: null,
ghosting: false,
- quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
@@ -648,7 +628,6 @@ var Sortable = {
// build options for the draggables
var options_for_draggable = {
revert: true,
- quiet: options.quiet,
scroll: options.scroll,
scrollSpeed: options.scrollSpeed,
scrollSensitivity: options.scrollSensitivity,
diff --git a/wp-includes/js/scriptaculous/effects.js b/wp-includes/js/scriptaculous/effects.js
index 596b62e..6b7e5c3 100644
--- a/wp-includes/js/scriptaculous/effects.js
+++ b/wp-includes/js/scriptaculous/effects.js
@@ -1,6 +1,6 @@
-// script.aculo.us effects.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+// script.aculo.us effects.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
// Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/)
@@ -45,10 +45,18 @@ Element.collectTextNodesIgnoreClass = function(element, className) {
Element.setContentZoom = function(element, percent) {
element = $(element);
element.setStyle({fontSize: (percent/100) + 'em'});
- if(Prototype.Browser.WebKit) window.scrollBy(0,0);
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
return element;
}
+Element.getOpacity = function(element){
+ return $(element).getStyle('opacity');
+}
+
+Element.setOpacity = function(element, value){
+ return $(element).setStyle({opacity:value});
+}
+
Element.getInlineOpacity = function(element){
return $(element).style.opacity || '';
}
@@ -81,7 +89,7 @@ var Effect = {
throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
var tagifyStyle = 'position:relative';
- if(Prototype.Browser.IE) tagifyStyle += ';zoom:1';
+ if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
element = $(element);
$A(element.childNodes).each( function(child) {
@@ -144,8 +152,7 @@ Effect.Transitions = {
return 1-pos;
},
flicker: function(pos) {
- var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
- return (pos > 1 ? 1 : pos);
+ return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
},
wobble: function(pos) {
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
@@ -172,7 +179,7 @@ Effect.ScopedQueue = Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
initialize: function() {
this.effects = [];
- this.interval = null;
+ this.interval = null;
},
_each: function(iterator) {
this.effects._each(iterator);
@@ -206,7 +213,7 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
this.effects.push(effect);
- if(!this.interval)
+ if(!this.interval)
this.interval = setInterval(this.loop.bind(this), 15);
},
remove: function(effect) {
@@ -219,7 +226,7 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
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);
+ if(this.effects[i]) this.effects[i].loop(timePos);
}
});
@@ -239,7 +246,7 @@ Effect.Queue = Effect.Queues.get('global');
Effect.DefaultOptions = {
transition: Effect.Transitions.sinoidal,
duration: 1.0, // seconds
- fps: 100, // 100= assume 66fps max.
+ fps: 60.0, // max. 60fps due to Effect.Queue implementation
sync: false, // true for combining
from: 0.0,
to: 1.0,
@@ -251,35 +258,11 @@ Effect.Base = function() {};
Effect.Base.prototype = {
position: null,
start: function(options) {
- function codeForEvent(options,eventName){
- return (
- (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +
- (options[eventName] ? 'this.options.'+eventName+'(this);' : '')
- );
- }
- if(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;
-
- eval('this.render = function(pos){ '+
- 'if(this.state=="idle"){this.state="running";'+
- codeForEvent(options,'beforeSetup')+
- (this.setup ? 'this.setup();':'')+
- codeForEvent(options,'afterSetup')+
- '};if(this.state=="running"){'+
- 'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+
- 'this.position=pos;'+
- codeForEvent(options,'beforeUpdate')+
- (this.update ? 'this.update(pos);':'')+
- codeForEvent(options,'afterUpdate')+
- '}}');
-
+ this.finishOn = this.startOn + (this.options.duration*1000);
this.event('beforeStart');
if(!this.options.sync)
Effect.Queues.get(typeof this.options.queue == 'string' ?
@@ -295,14 +278,31 @@ Effect.Base.prototype = {
this.event('afterFinish');
return;
}
- var pos = (timePos - this.startOn) / this.totalTime,
- frame = Math.round(pos * this.totalFrames);
+ var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
+ var frame = Math.round(pos * this.options.fps * this.options.duration);
if(frame > this.currentFrame) {
this.render(pos);
this.currentFrame = frame;
}
}
},
+ render: function(pos) {
+ if(this.state == 'idle') {
+ this.state = 'running';
+ this.event('beforeSetup');
+ if(this.setup) this.setup();
+ this.event('afterSetup');
+ }
+ if(this.state == 'running') {
+ if(this.options.transition) pos = this.options.transition(pos);
+ pos *= (this.options.to-this.options.from);
+ pos += this.options.from;
+ this.position = pos;
+ this.event('beforeUpdate');
+ if(this.update) this.update(pos);
+ this.event('afterUpdate');
+ }
+ },
cancel: function() {
if(!this.options.sync)
Effect.Queues.get(typeof this.options.queue == 'string' ?
@@ -358,7 +358,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
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))
+ if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom: 1});
var options = Object.extend({
from: this.element.getOpacity() || 0.0,
@@ -953,7 +953,7 @@ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
effect.element.addClassName(effect.options.style);
effect.transforms.each(function(transform) {
if(transform.style != 'opacity')
- effect.element.style[transform.style] = '';
+ effect.element.style[transform.style.camelize()] = '';
});
}
} else this.style = options.style.parseStyle();
@@ -969,28 +969,26 @@ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
});
}
this.transforms = this.style.map(function(pair){
- var property = pair[0], value = pair[1], unit = null;
+ var property = pair[0].underscore().dasherize(), 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))
+ if(/MSIE/.test(navigator.userAgent) && !window.opera && (!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;
- }
+ } 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(),
+ return $H({
+ style: property,
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) ||
@@ -1002,19 +1000,17 @@ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
});
},
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() :
+ var style = $H(), value = null;
+ this.transforms.each(function(transform){
+ value = transform.unit=='color' ?
+ $R(0,2).inject('#',function(m,v,i){
+ return m+(Math.round(transform.originalValue[i]+
+ (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) :
transform.originalValue + Math.round(
((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
- this.element.setStyle(style, true);
+ style[transform.style] = value;
+ });
+ this.element.setStyle(style);
}
});
@@ -1061,14 +1057,14 @@ Element.CSS_PROPERTIES = $w(
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
String.prototype.parseStyle = function(){
- var element = document.createElement('div');
+ var element = Element.extend(document.createElement('div'));
element.innerHTML = '<div style="' + this + '"></div>';
- var style = element.childNodes[0].style, styleRules = $H();
+ var style = element.down().style, styleRules = $H();
Element.CSS_PROPERTIES.each(function(property){
if(style[property]) styleRules[property] = style[property];
});
- if(Prototype.Browser.IE && this.indexOf('opacity') > -1) {
+ if(/MSIE/.test(navigator.userAgent) && !window.opera && this.indexOf('opacity') > -1) {
styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
}
return styleRules;
@@ -1079,13 +1075,13 @@ Element.morph = function(element, style) {
return element;
};
-['getInlineOpacity','forceRerendering','setContentZoom',
+['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(
function(f) { Element.Methods[f] = Element[f]; }
);
Element.Methods.visualEffect = function(element, effect, options) {
- s = effect.dasherize().camelize();
+ s = effect.gsub(/_/, '-').camelize();
effect_class = s.charAt(0).toUpperCase() + s.substring(1);
new Effect[effect_class](element, options);
return $(element);
diff --git a/wp-includes/js/scriptaculous/scriptaculous.js b/wp-includes/js/scriptaculous/scriptaculous.js
index 5f403a3..0844cef 100644
--- a/wp-includes/js/scriptaculous/scriptaculous.js
+++ b/wp-includes/js/scriptaculous/scriptaculous.js
@@ -1,6 +1,6 @@
-// script.aculo.us scriptaculous.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+// script.aculo.us scriptaculous.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005, 2006 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
@@ -24,32 +24,25 @@
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = {
- Version: '1.7.1_beta2',
+ Version: '1.7.0',
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
},
- REQUIRED_PROTOTYPE: '1.5.1',
load: function() {
- function convertVersionString(versionString){
- var r = versionString.split('.');
- return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
- }
-
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);
+ parseFloat(Prototype.Version.split(".")[0] + "." +
+ Prototype.Version.split(".")[1]) < 1.5)
+ throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
$A(document.getElementsByTagName("script")).findAll( function(s) {
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
}).each( function(s) {
var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);
- (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
+ (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
}
diff --git a/wp-includes/js/scriptaculous/slider.js b/wp-includes/js/scriptaculous/slider.js
index 4db286b..4899587 100644
--- a/wp-includes/js/scriptaculous/slider.js
+++ b/wp-includes/js/scriptaculous/slider.js
@@ -1,6 +1,6 @@
-// script.aculo.us slider.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+// script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005-2007 Marty Haught, Thomas Fuchs
+// Copyright (c) 2005, 2006 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/
@@ -242,7 +242,8 @@ Control.Slider.prototype = {
if(this.active) {
if(!this.dragging) this.dragging = true;
this.draw(event);
- if(Prototype.Browser.WebKit) window.scrollBy(0,0);
+ // fix AppleWebKit rendering
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
Event.stop(event);
}
},
diff --git a/wp-includes/js/scriptaculous/sound.js b/wp-includes/js/scriptaculous/sound.js
deleted file mode 100644
index fab10e8..0000000
--- a/wp-includes/js/scriptaculous/sound.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// script.aculo.us sound.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
-
-// Copyright (c) 2005-2007 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;
- if (Prototype.Browser.IE) {
- var sound = document.createElement('bgsound');
- sound.setAttribute('id','sound_'+options.track+'_'+options.id);
- sound.setAttribute('src',options.url);
- sound.setAttribute('loop','1');
- sound.setAttribute('autostart','true');
- $$('body')[0].appendChild(sound);
- }
- else
- new Insertion.Bottom($$('body')[0], 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
- Sound.play = function(){}
-}
diff --git a/wp-includes/js/scriptaculous/unittest.js b/wp-includes/js/scriptaculous/unittest.js
index f46cca4..f272ab2 100644
--- a/wp-includes/js/scriptaculous/unittest.js
+++ b/wp-includes/js/scriptaculous/unittest.js
@@ -1,8 +1,8 @@
-// script.aculo.us unittest.js v1.7.1_beta2, Sat Apr 28 15:20:12 CEST 2007
+// script.aculo.us unittest.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
-// (c) 2005-2007 Michael Schuerig (http://www.schuerig.de/michael/)
+// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com)
+// (c) 2005, 2006 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/
diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
index 68ca7ba..04eba01 100644
--- a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
+++ b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
@@ -4,10 +4,6 @@ if (navigator.userAgent.indexOf('Mac OS') != -1) {
// Mac OS browsers use Ctrl to hit accesskeys
var metaKey = 'Ctrl';
}
-else if (navigator.userAgent.indexOf('Firefox/2') != -1) {
-// Firefox 2.x uses Alt+Shift to hit accesskeys
- var metaKey = 'Alt+Shift';
-}
else {
var metaKey = 'Alt';
}
@@ -35,3 +31,4 @@ numlist_desc : 'Ordered list (' + metaKey + '+o)',
outdent_desc : 'Outdent (' + metaKey + '+w)',
indent_desc : 'Indent list/blockquote (' + metaKey + '+q)'
});
+
diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php
index de01c67..5c2c1c8 100644
--- a/wp-includes/js/tinymce/tiny_mce_config.php
+++ b/wp-includes/js/tinymce/tiny_mce_config.php
@@ -29,7 +29,7 @@
$plugins = apply_filters('mce_plugins', $plugins);
$plugins = implode($plugins, ',');
- $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', 'wp_adv_start', 'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'wp_adv_end'));
+ $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, ',');
$mce_buttons_2 = apply_filters('mce_buttons_2', array());
diff --git a/wp-includes/js/tinymce/tiny_mce_popup.js b/wp-includes/js/tinymce/tiny_mce_popup.js
index c4db092..e6c91c3 100644
--- a/wp-includes/js/tinymce/tiny_mce_popup.js
+++ b/wp-includes/js/tinymce/tiny_mce_popup.js
@@ -1,5 +1,3 @@
-
-
// Some global instances, this will be filled later
var tinyMCE = null, tinyMCELang = null;
diff --git a/wp-includes/kses.php b/wp-includes/kses.php
index 4b5a284..e96cee2 100644
--- a/wp-includes/kses.php
+++ b/wp-includes/kses.php
@@ -18,207 +18,27 @@ if (!defined('CUSTOM_TAGS'))
// You can override this in your my-hacks.php file
if (!CUSTOM_TAGS) {
- $allowedposttags = array(
- 'address' => array(),
- 'a' => array(
- 'href' => array(), 'title' => array(),
- 'rel' => array(), 'rev' => array(),
- 'name' => array()
- ),
- 'abbr' => array(
- 'title' => array(), 'class' => array()
- ),
- 'acronym' => array(
- 'title' => array()
- ),
- 'b' => array(),
- 'big' => array(),
- 'blockquote' => array(
- 'cite' => array(), 'xml:lang' => array(),
- 'lang' => array()
- ),
- 'br' => array(),
- 'button' => array(
- 'disabled' => array(), 'name' => array(),
- 'type' => array(), 'value' => array()
- ),
- 'caption' => array(
- 'align' => array()
- ),
- 'code' => array(),
- 'col' => array(
- 'align' => array(), 'char' => array(),
- 'charoff' => array(), 'span' => array(),
- 'valign' => array(), 'width' => array()
- ),
- 'del' => array(
- 'datetime' => array()
- ),
- 'dd' => array(),
- 'div' => array(
- 'align' => array(), 'xml:lang' => array(),
- 'lang' => array()
- ),
- 'dl' => array(),
- 'dt' => array(),
- 'em' => array(),
- 'fieldset' => array(),
- 'font' => array(
- 'color' => array(), 'face' => array(),
- 'size' => array()
- ),
- 'form' => array(
- 'action' => array(), 'accept' => array(),
- 'accept-charset' => array(), 'enctype' => array(),
- 'method' => array(), 'name' => array(),
- 'target' => array()
- ),
- 'h1' => array(
- 'align' => array()
- ),
- 'h2' => array(
- 'align' => array()
- ),
- 'h3' => array(
- 'align' => array()
- ),
- 'h4' => array(
- 'align' => array()
- ),
- 'h5' => array(
- 'align' => array()
- ),
- 'h6' => array(
- 'align' => array()
- ),
- 'hr' => array(
- 'align' => array(), 'noshade' => array(),
- 'size' => array(), 'width' => array()
- ),
- 'i' => array(),
- 'img' => array(
- 'alt' => array(), 'align' => array(),
- 'border' => array(), 'height' => array(),
- 'hspace' => array(), 'longdesc' => array(),
- 'vspace' => array(), 'src' => array(),
- 'width' => array()
- ),
- 'ins' => array(
- 'datetime' => array(), 'cite' => array()
- ),
- 'kbd' => array(),
- 'label' => array(
- 'for' => array()
- ),
- 'legend' => array(
- 'align' => array()
- ),
- 'li' => array(),
- 'p' => array(
- 'align' => array(), 'xml:lang' => array(),
- 'lang' => array()
- ),
- 'pre' => array(
- 'width' => array()
- ),
- 'q' => array(
- 'cite' => array()
- ),
- 's' => array(),
- 'strike' => array(),
- 'strong' => array(),
- 'sub' => array(),
- 'sup' => array(),
- 'table' => array(
- 'align' => array(), 'bgcolor' => array(),
- 'border' => array(), 'cellpadding' => array(),
- 'cellspacing' => array(), 'rules' => 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(),
- 'colspan' => array(), 'headers' => array(),
- 'height' => array(), 'nowrap' => array(),
- 'rowspan' => array(), 'scope' => array(),
- 'valign' => array(), 'width' => array()
- ),
- 'textarea' => array(
- 'cols' => array(), 'rows' => array(),
- 'disabled' => array(), 'name' => array(),
- 'readonly' => array()
- ),
- 'tfoot' => array(
- 'align' => array(), 'char' => array(),
- 'charoff' => array(), 'valign' => array()
- ),
- 'th' => array(
- 'abbr' => array(), 'align' => array(),
- 'axis' => array(), 'bgcolor' => array(),
- 'char' => array(), 'charoff' => 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(), 'valign' => array()
- ),
- 'title' => array(),
- 'tr' => array(
- 'align' => array(), 'bgcolor' => array(),
- 'char' => array(), 'charoff' => array(),
- 'valign' => array()
- ),
- 'tt' => array(),
- 'u' => array(),
- 'ul' => array(),
- 'ol' => array(),
- 'var' => array()
- );
-
- $allowedtags = array(
- 'a' => array(
- 'href' => array(), 'title' => array()
- ),
- 'abbr' => array(
- 'title' => array()
- ),
- 'acronym' => array(
- 'title' => array()
- ),
- 'b' => array(),
- 'blockquote' => array(
- 'cite' => array()
- ),
+ $allowedposttags = array ('address' => array (), 'a' => array ('href' => array (), 'title' => array (), 'rel' => array (), 'rev' => array (), 'name' => array ()), 'abbr' => array ('title' => array ()), 'acronym' => array ('title' => array ()), 'b' => array (), 'big' => array (), 'blockquote' => array ('cite' => array ()), 'br' => array (), 'button' => array ('disabled' => array (), 'name' => array (), 'type' => array (), 'value' => array ()), 'caption' => array ('align' => array ()), 'code' => array (), 'col' => array ('align' => array (), 'char' => array (), 'charoff' => array (), 'span' => array (), 'valign' => array (), 'width' => array ()), 'del' => array ('datetime' => array ()), 'dd' => array (), 'div' => array ('align' => array ()), 'dl' => array (), 'dt' => array (), 'em' => array (), 'fieldset' => array (), 'font' => array ('color' => array (), 'face' => array (), 'size' => array ()), 'form' => array ('action' => array (), 'accept' => array (), 'accept-charset' => array (), 'enctype' => array (), 'method' => array (), 'name' => array (), 'target' => array ()), 'h1' => array ('align' => array ()), 'h2' => array ('align' => array ()), 'h3' => array ('align' => array ()), 'h4' => array ('align' => array ()), 'h5' => array ('align' => array ()), 'h6' => array ('align' => array ()), 'hr' => array ('align' => array (), 'noshade' => array (), 'size' => array (), 'width' => array ()), 'i' => array (), 'img' => array ('alt' => array (), 'align' => array (), 'border' => array (), 'height' => array (), 'hspace' => array (), 'longdesc' => array (), 'vspace' => array (), 'src' => array (), 'width' => array ()), 'ins' => array ('datetime' => array (), 'cite' => array ()), 'kbd' => array (), 'label' => array ('for' => array ()), 'legend' => array ('align' => array ()), 'li' => array (), 'p' => array ('align' => array ()), 'pre' => array ('width' => array ()), 'q' => array ('cite' => array ()), 's' => array (), 'strike' => array (), 'strong' => array (), 'sub' => array (), 'sup' => array (), 'table' => array ('align' => array (), 'bgcolor' => array (), 'border' => array (), 'cellpadding' => array (), 'cellspacing' => array (), 'rules' => 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 (), 'colspan' => array (), 'headers' => array (), 'height' => array (), 'nowrap' => array (), 'rowspan' => array (), 'scope' => array (), 'valign' => array (), 'width' => array ()), 'textarea' => array ('cols' => array (), 'rows' => array (), 'disabled' => array (), 'name' => array (), 'readonly' => array ()), 'tfoot' => array ('align' => array (), 'char' => array (), 'charoff' => array (), 'valign' => array ()), 'th' => array ('abbr' => array (), 'align' => array (), 'axis' => array (), 'bgcolor' => array (), 'char' => array (), 'charoff' => 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 (), 'valign' => array ()), 'title' => array (), 'tr' => array ('align' => array (), 'bgcolor' => array (), 'char' => array (), 'charoff' => array (), 'valign' => array ()), 'tt' => array (), 'u' => array (), 'ul' => array (), 'ol' => array (), 'var' => array () );
+ $allowedtags = array ('a' => array ('href' => array (), 'title' => array ()), 'abbr' => array ('title' => array ()), 'acronym' => array ('title' => array ()), 'b' => array (), 'blockquote' => array ('cite' => array ()),
// 'br' => array(),
- 'code' => array(),
+ 'code' => array (),
// 'del' => array('datetime' => array()),
// 'dd' => array(),
// 'dl' => array(),
// 'dt' => array(),
- 'em' => array(),
- 'i' => array(),
+ 'em' => array (), 'i' => array (),
// 'ins' => array('datetime' => array(), 'cite' => array()),
// 'li' => array(),
// 'ol' => array(),
// 'p' => array(),
// 'q' => array(),
- 'strike' => array(),
- 'strong' => array(),
+ 'strike' => array (), 'strong' => array (),
// 'sub' => array(),
// 'sup' => array(),
// 'u' => array(),
// 'ul' => array(),
);
}
-
function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'))
###############################################################################
# This function makes sure that only the allowed HTML element names, attribute
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 99b8ae0..2a05f93 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -77,6 +77,8 @@ function get_permalink($id = 0) {
$category = '';
if (strpos($permalink, '%category%') !== false) {
$cats = get_the_category($post->ID);
+ if ( $cats )
+ usort($cats, '_get_the_category_usort_by_ID'); // order by ID
$category = $cats[0]->category_nicename;
if ( $parent=$cats[0]->category_parent )
$category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
@@ -109,7 +111,7 @@ function get_permalink($id = 0) {
}
// get permalink from post ID
-function post_permalink($post_id = 0, $deprecated = '') {
+function post_permalink($post_id = 0, $mode = '') { // $mode legacy
return get_permalink($post_id);
}
@@ -273,80 +275,39 @@ function get_post_comments_feed_link($post_id = '', $feed = 'rss2') {
return apply_filters('post_comments_feed_link', $url);
}
-function get_edit_post_link( $id = 0 ) {
- $post = &get_post( $id );
-
- if ( $post->post_type == 'attachment' ) {
- return;
- } elseif ( $post->post_type == 'page' ) {
- if ( !current_user_can( 'edit_page', $post->ID ) )
- return;
-
- $file = 'page';
- } else {
- if ( !current_user_can( 'edit_post', $post->ID ) )
- return;
-
- $file = 'post';
- }
-
- return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&amp;post=' . $post->ID, $post->ID );
-}
-
-function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
+function edit_post_link($link = 'Edit This', $before = '', $after = '') {
global $post;
- if ( $post->post_type == 'attachment' ) {
+ if ( is_attachment() )
return;
- } elseif ( $post->post_type == 'page' ) {
- if ( !current_user_can( 'edit_page', $post->ID ) )
+
+ if( $post->post_type == 'page' ) {
+ if ( ! current_user_can('edit_page', $post->ID) )
return;
-
$file = 'page';
} else {
- if ( !current_user_can( 'edit_post', $post->ID ) )
+ if ( ! current_user_can('edit_post', $post->ID) )
return;
-
$file = 'post';
}
- $link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
- echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
+ $location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&amp;post=$post->ID";
+ echo $before . "<a href=\"$location\">$link</a>" . $after;
}
-function get_edit_comment_link( $comment_id = 0 ) {
- $comment = &get_comment( $comment_id );
- $post = &get_post( $comment->comment_post_ID );
-
- if ( $post->post_type == 'attachment' ) {
- return;
- } elseif ( $post->post_type == 'page' ) {
- if ( !current_user_can( 'edit_page', $post->ID ) )
- return;
- } else {
- if ( !current_user_can( 'edit_post', $post->ID ) )
- return;
- }
+function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
+ global $post, $comment;
- $location = get_bloginfo( 'wpurl' ) . '/wp-admin/comment.php?action=editcomment&amp;c=' . $comment->comment_ID;
- return apply_filters( 'get_edit_comment_link', $location );
-}
-
-function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
- global $comment, $post;
-
- if ( $post->post_type == 'attachment' ) {
- return;
- } elseif ( $post->post_type == 'page' ) {
- if ( !current_user_can( 'edit_page', $post->ID ) )
+ if( $post->post_type == 'page' ){
+ if ( ! current_user_can('edit_page', $post->ID) )
return;
} else {
- if ( !current_user_can( 'edit_post', $post->ID ) )
+ if ( ! current_user_can('edit_post', $post->ID) )
return;
}
- $link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
- echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
+ $location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&amp;c=$comment->comment_ID";
+ echo $before . "<a href='$location'>$link</a>" . $after;
}
// Navigation links
@@ -463,55 +424,75 @@ function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat =
function get_pagenum_link($pagenum = 1) {
global $wp_rewrite;
-
- $pagenum = (int) $pagenum;
-
- $request = remove_query_arg( 'paged' );
-
+
+ $qstr = $_SERVER['REQUEST_URI'];
+
+ $page_querystring = "paged";
+ $page_modstring = "page/";
+ $page_modregex = "page/?";
+ $permalink = 0;
+
$home_root = parse_url(get_option('home'));
$home_root = $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() ) {
- $base = trailingslashit( get_bloginfo( 'home' ) );
-
- if ( $pagenum > 1 ) {
- $result = add_query_arg( 'paged', $pagenum, $base . $request );
- } else {
- $result = $base . $request;
- }
+ $home_root = trailingslashit($home_root);
+ $qstr = preg_replace('|^'. $home_root . '|', '', $qstr);
+ $qstr = preg_replace('|^/+|', '', $qstr);
+
+ $index = $_SERVER['PHP_SELF'];
+ $index = preg_replace('|^'. $home_root . '|', '', $index);
+ $index = preg_replace('|^/+|', '', $index);
+
+ // if we already have a QUERY style page string
+ if ( stripos( $qstr, $page_querystring ) !== false ) {
+ $replacement = "$page_querystring=$pagenum";
+ $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr);
+ // if we already have a mod_rewrite style page string
+ } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ) {
+ $permalink = 1;
+ $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr);
+
+ // if we don't have a page string at all ...
+ // lets see what sort of URL we have...
} else {
- $request = preg_replace( '|/?page/(.+)/?$|', '', $request);
-
- $qs_regex = '|\?.*?$|';
- preg_match( $qs_regex, $request, $qs_match );
-
- if ( $qs_match[0] ) {
- $query_string = $qs_match[0];
- $request = preg_replace( $qs_regex, '', $request );
+ // we need to know the way queries are being written
+ // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten
+ if ( stripos( $qstr, '?' ) !== false ) {
+ // so append the query string (using &, since we already have ?)
+ $qstr .= '&amp;' . $page_querystring . '=' . $pagenum;
+ // otherwise, it could be rewritten, OR just the default index ...
+ } elseif( '' != get_option('permalink_structure') && ! is_admin() ) {
+ $permalink = 1;
+ $index = $wp_rewrite->index;
+ // If it's not a path info permalink structure, trim the index.
+ if ( !$wp_rewrite->using_index_permalinks() ) {
+ $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr);
+ } else {
+ // If using path info style permalinks, make sure the index is in
+ // the URL.
+ if ( strpos($qstr, $index) === false )
+ $qstr = '/' . $index . $qstr;
+ }
+
+ $qstr = trailingslashit($qstr) . $page_modstring . $pagenum;
} else {
- $query_string = '';
+ $qstr = $index . '?' . $page_querystring . '=' . $pagenum;
}
-
- $base = trailingslashit( get_bloginfo( 'url' ) );
-
- if ( $wp_rewrite->using_index_permalinks() && $pagenum > 1 ) {
- $base .= 'index.php/';
- }
-
- if ( $pagenum > 1 ) {
- $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
- } else {
- $request = user_trailingslashit( $request );
- }
-
- $result = $base . $request . $query_string;
}
-
- return $result;
+
+ $qstr = preg_replace('|^/+|', '', $qstr);
+ if ( $permalink )
+ $qstr = user_trailingslashit($qstr, 'paged');
+
+ // showing /page/1/ or ?paged=1 is redundant
+ if ( 1 === $pagenum ) {
+ $qstr = str_replace(user_trailingslashit('index.php/page/1', 'paged'), '', $qstr); // for PATHINFO style
+ $qstr = str_replace(user_trailingslashit('page/1', 'paged'), '', $qstr); // for mod_rewrite style
+ $qstr = remove_query_arg('paged', $qstr); // for query style
+ }
+
+ $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', trailingslashit( get_option('home') ) . $qstr );
+
+ return $qstr;
}
function get_next_posts_page_link($max_page = 0) {
diff --git a/wp-includes/locale.php b/wp-includes/locale.php
index af3fc13..0c8ec8b 100644
--- a/wp-includes/locale.php
+++ b/wp-includes/locale.php
@@ -87,18 +87,6 @@ class WP_Locale {
$this->meridiem['AM'] = __('AM');
$this->meridiem['PM'] = __('PM');
- // Numbers formatting
- // See http://php.net/number_format
-
- $trans = __('number_format_decimals');
- $this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans;
-
- $trans = __('number_format_decimal_point');
- $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
-
- $trans = __('number_format_thousands_sep');
- $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
-
// Import global locale vars set during inclusion of $locale.php.
foreach ( $this->locale_vars as $var ) {
if ( isset($GLOBALS[$var]) )
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 949e603..3668635 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -162,7 +162,7 @@ function get_userdatabylogin($user_login) {
}
endif;
-if ( !function_exists('wp_mail') ) :
+if ( !function_exists( 'wp_mail' ) ) :
function wp_mail($to, $subject, $message, $headers = '') {
global $phpmailer;
@@ -174,11 +174,11 @@ function wp_mail($to, $subject, $message, $headers = '') {
$mail = compact('to', 'subject', 'message', 'headers');
$mail = apply_filters('wp_mail', $mail);
- extract($mail);
+ extract($mail, EXTR_SKIP);
if ( $headers == '' ) {
$headers = "MIME-Version: 1.0\n" .
- "From: " . get_option('admin_email') . "\n" .
+ "From: " . apply_filters('wp_mail_from', get_option('admin_email') ) . "\n" .
"Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
}
@@ -230,6 +230,8 @@ if ( !function_exists('wp_login') ) :
function wp_login($username, $password, $already_md5 = false) {
global $wpdb, $error;
+ $username = sanitize_user($username);
+
if ( '' == $username )
return false;
diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
index b8bf524..c573ec1 100644
--- a/wp-includes/plugin.php
+++ b/wp-includes/plugin.php
@@ -97,14 +97,12 @@ function merge_filters($tag) {
* @return boolean Whether the function is removed.
*/
function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
- $function_to_remove = serialize($function_to_remove);
-
- $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
+ global $wp_filter, $merged_filters;
- unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
- unset($GLOBALS['merged_filters'][$tag]);
+ unset($GLOBALS['wp_filter'][$tag][$priority][serialize($function_to_remove)]);
+ unset( $merged_filters[ $tag ] );
- return $r;
+ return true;
}
/**
@@ -222,7 +220,7 @@ function do_action_ref_array($tag, $args) {
* @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_filter($tag, $function_to_remove, $priority, $accepted_args);
}
//
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index cee198b..f294914 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -129,23 +129,21 @@ function get_the_excerpt($fakeit = true) {
return apply_filters('get_the_excerpt', $output);
}
-function has_excerpt( $id = 0 ) {
- $post = &get_post( $id );
- return ( !empty( $post->post_excerpt ) );
-}
function wp_link_pages($args = '') {
- $defaults = array(
- 'before' => '<p>' . __('Pages:'), 'after' => '</p>',
- 'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
- 'previouspagelink' => __('Previous page'), 'pagelink' => '%',
- 'more_file' => '', 'echo' => 1
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
-
- global $post, $id, $page, $numpages, $multipage, $more, $pagenow;
+ global $post;
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
+ 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'more_file' => '', 'echo' => 1);
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
+
+ global $id, $page, $numpages, $multipage, $more, $pagenow;
if ( $more_file != '' )
$file = $more_file;
else
@@ -249,14 +247,15 @@ function the_meta() {
//
function wp_dropdown_pages($args = '') {
- $defaults = array(
- 'depth' => 0, 'child_of' => 0,
- 'selected' => 0, 'echo' => 1,
- 'name' => 'page_id', 'show_option_none' => ''
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1,
+ 'name' => 'page_id', 'show_option_none' => '');
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
$pages = get_pages($r);
$output = '';
@@ -278,16 +277,14 @@ function wp_dropdown_pages($args = '') {
}
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'
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $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');
+ $r = array_merge($defaults, $r);
$output = '';
$current_page = 0;
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 9c6929a..db0472d 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -27,25 +27,23 @@ function update_attached_file( $attachment_id, $file ) {
function &get_children($args = '', $output = OBJECT) {
global $post_cache, $wpdb, $blog_id;
-
- if ( empty( $args ) ) {
- if ( isset( $GLOBALS['post'] ) ) {
- $args = 'post_parent=' . (int) $GLOBALS['post']->post_parent;
- } else {
+
+ if ( empty($args) ) {
+ if ( isset($GLOBALS['post']) )
+ $r = array('post_parent' => & $GLOBALS['post']->post_parent);
+ else
return false;
- }
- } elseif ( is_object( $args ) ) {
- $args = 'post_parent=' . (int) $args->post_parent;
- } elseif ( is_numeric( $args ) ) {
- $args = 'post_parent=' . (int) $args;
- }
-
- $defaults = array(
- 'numberposts' => -1, 'post_type' => '',
- 'post_status' => '', 'post_parent' => 0
- );
-
- $r = wp_parse_args( $args, $defaults );
+ } elseif ( is_object($args) )
+ $r = array('post_parent' => $post->post_parent);
+ elseif ( is_numeric($args) )
+ $r = array('post_parent' => $args);
+ elseif ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('numberposts' => -1, 'post_type' => '', 'post_status' => '', 'post_parent' => 0);
+ $r = array_merge($defaults, $r);
$children = get_posts( $r );
@@ -174,19 +172,17 @@ function get_post_type($post = false) {
function get_posts($args) {
global $wpdb;
-
- $defaults = array(
- 'numberposts' => 5, 'offset' => 0,
- 'category' => 0, 'orderby' => 'post_date',
- 'order' => 'DESC', 'include' => '',
- 'exclude' => '', 'meta_key' => '',
- 'meta_value' =>'', 'post_type' => 'post',
- 'post_status' => 'publish', 'post_parent' => 0
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
-
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => 0,
+ 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '',
+ 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'publish', 'post_parent' => 0);
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
$numberposts = (int) $numberposts;
$offset = (int) $offset;
$category = (int) $category;
@@ -494,7 +490,7 @@ function wp_insert_post($postarr = array()) {
$postarr = get_object_vars($postarr);
// export array as variables
- extract($postarr);
+ extract($postarr, EXTR_SKIP);
// Are we updating or creating?
$update = false;
@@ -649,7 +645,7 @@ function wp_insert_post($postarr = array()) {
$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
}
- wp_set_post_categories( $post_ID, $post_category );
+ wp_set_post_categories($post_ID, $post_category);
if ( 'page' == $post_type ) {
clean_page_cache($post_ID);
@@ -885,7 +881,7 @@ function trackback_url_list($tb_list, $post_id) {
$postdata = wp_get_single_post($post_id, ARRAY_A);
// import postdata as variables
- extract($postdata);
+ extract($postdata, EXTR_SKIP);
// form an excerpt
$excerpt = strip_tags($post_excerpt?$post_excerpt:$post_content);
@@ -911,7 +907,7 @@ function get_all_page_ids() {
if ( ! $page_ids = wp_cache_get('all_page_ids', 'pages') ) {
$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
- wp_cache_set('all_page_ids', $page_ids, 'pages');
+ wp_cache_add('all_page_ids', $page_ids, 'pages');
}
return $page_ids;
@@ -954,7 +950,7 @@ function &get_page(&$page, $output = OBJECT) {
return get_post($_page, $output);
// Potential issue: we're not checking to see if the post_type = 'page'
// So all non-'post' posts will get cached as pages.
- wp_cache_set($_page->ID, $_page, 'pages');
+ wp_cache_add($_page->ID, $_page, 'pages');
}
}
}
@@ -1062,17 +1058,16 @@ function get_page_uri($page_id) {
function &get_pages($args = '') {
global $wpdb;
-
- $defaults = array(
- 'child_of' => 0, 'sort_order' => 'ASC',
- 'sort_column' => 'post_title', 'hierarchical' => 1,
- 'exclude' => '', 'include' => '',
- 'meta_key' => '', 'meta_value' => '',
- 'authors' => ''
- );
-
- $r = wp_parse_args( $args, $defaults );
- extract( $r );
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title',
+ 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '');
+ $r = array_merge($defaults, $r);
+ extract($r, EXTR_SKIP);
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_pages', 'page' ) )
@@ -1226,7 +1221,7 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
$object = get_object_vars($object);
// Export array as variables
- extract($object);
+ extract($object, EXTR_SKIP);
// Get the basics.
$post_content = apply_filters('content_save_pre', $post_content);
diff --git a/wp-includes/registration.php b/wp-includes/registration.php
index 6c03206..cd387fd 100644
--- a/wp-includes/registration.php
+++ b/wp-includes/registration.php
@@ -32,7 +32,7 @@ function validate_username( $username ) {
function wp_insert_user($userdata) {
global $wpdb;
- extract($userdata);
+ extract($userdata, EXTR_SKIP);
// Are we updating or creating?
if ( !empty($ID) ) {
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index eb10bf7..2f440ab 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -1,905 +1,904 @@
-<?php
-
-/* WP_Rewrite API
-*******************************************************************************/
-
-//Add a straight rewrite rule
-function add_rewrite_rule($regex, $redirect) {
- global $wp_rewrite;
- $wp_rewrite->add_rule($regex, $redirect);
-}
-
-//Add a new tag (like %postname%)
-//warning: you must call this on init or earlier, otherwise the query var addition stuff won't work
-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 a new feed type like /atom1/
-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_action($hook, $function, 10, 1);
- add_action($hook, $function, 10, 1);
- return $hook;
-}
-
-define('EP_PERMALINK', 1 );
-define('EP_ATTACHMENT', 2 );
-define('EP_DATE', 4 );
-define('EP_YEAR', 8 );
-define('EP_MONTH', 16 );
-define('EP_DAY', 32 );
-define('EP_ROOT', 64 );
-define('EP_COMMENTS', 128 );
-define('EP_SEARCH', 256 );
-define('EP_CATEGORIES', 512 );
-define('EP_AUTHORS', 2048);
-define('EP_PAGES', 4096);
-//pseudo-places
-define('EP_NONE', 0 );
-define('EP_ALL', 8191);
-
-//and an endpoint, like /trackback/
-function add_rewrite_endpoint($name, $places) {
- global $wp_rewrite;
- $wp_rewrite->add_endpoint($name, $places);
-}
-
-// examine a url (supposedly from this blog) and try to
-// determine the post ID it represents.
-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
- preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
- $id = intval($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;
-
- // $url cleanup by Mark Jaquith
- // This fixes things like #anchors, ?query=strings, missing 'www.',
- // added 'www.', or added 'index.php/' that will mess up our WP_Query
- // and return a false negative
-
- // 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(get_option('home'), '://www.') && false === strpos($url, '://www.') )
- $url = str_replace('://', '://www.', $url);
-
- // Strip 'www.' if it is present and shouldn't be
- if ( false === strpos(get_option('home'), '://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, get_option('home')) ) {
- // Chop off http://domain.com
- $url = str_replace(get_option('home'), '', $url);
- } else {
- // Chop off /path/to/blog
- $home_path = parse_url(get_option('home'));
- $home_path = $home_path['path'];
- $url = str_replace($home_path, '', $url);
- }
-
- // Trim leading and lagging slashes
- $url = trim($url, '/');
-
- $request = $url;
-
- // Done with cleanup
-
- // Look for matches.
- $request_match = $request;
- foreach ($rewrite as $match => $query) {
- // If the requesting file is the anchor of the match, prepend it
- // to the path info.
- if ( (! empty($url)) && (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.
- eval("\$query = \"$query\";");
- $query = new WP_Query($query);
- if ( $query->is_single || $query->is_page )
- return $query->post->ID;
- else
- return 0;
- }
- }
- return 0;
-}
-
-/* WP_Rewrite class
-*******************************************************************************/
-
-class WP_Rewrite {
- var $permalink_structure;
- var $use_trailing_slashes;
- var $category_base;
- var $category_structure;
- var $author_base = 'author';
- var $author_structure;
- var $date_structure;
- var $page_structure;
- var $search_base = 'search';
- var $search_structure;
- var $comments_base = 'comments';
- var $feed_base = 'feed';
- var $comments_feed_structure;
- var $feed_structure;
- var $front;
- var $root = '';
- var $index = 'index.php';
- var $matches = '';
- var $rules;
- var $extra_rules; //those not generated by the class, see add_rewrite_rule()
- var $non_wp_rules; //rules that don't redirect to WP's index.php
- var $endpoints;
- var $use_verbose_rules = false;
- var $rewritecode =
- array(
- '%year%',
- '%monthnum%',
- '%day%',
- '%hour%',
- '%minute%',
- '%second%',
- '%postname%',
- '%post_id%',
- '%category%',
- '%author%',
- '%pagename%',
- '%search%'
- );
-
- 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]+)',
- '(.+?)',
- '(.+?)',
- '([^/]+)',
- '([^/]+)',
- '(.+)'
- );
-
- var $queryreplace =
- array (
- 'year=',
- 'monthnum=',
- 'day=',
- 'hour=',
- 'minute=',
- 'second=',
- 'name=',
- 'p=',
- 'category_name=',
- 'author_name=',
- 'pagename=',
- 's='
- );
-
- var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
-
- function using_permalinks() {
- if (empty($this->permalink_structure))
- return false;
- else
- return true;
- }
-
- 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;
- }
-
- function using_mod_rewrite_permalinks() {
- if ( $this->using_permalinks() && ! $this->using_index_permalinks())
- return true;
- else
- return false;
- }
-
- function preg_index($number) {
- $match_prefix = '$';
- $match_suffix = '';
-
- if (! empty($this->matches)) {
- $match_prefix = '$' . $this->matches . '[';
- $match_suffix = ']';
- }
-
- return "$match_prefix$number$match_suffix";
- }
-
- function page_rewrite_rules() {
- $uris = get_option('page_uris');
- $attachment_uris = get_option('page_attachment_uris');
-
- $rewrite_rules = array();
- $page_structure = $this->get_page_permastruct();
- 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;
- }
-
- 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 ($tokens[0] as $token) {
- if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
- $front = $front . 'date/';
- break;
- }
- $tok_index++;
- }
-
- $this->date_structure = $front . $date_endian;
-
- return $this->date_structure;
- }
-
- 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;
- }
-
- 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;
- }
-
- function get_day_permastruct() {
- return $this->get_date_permastruct($this->permalink_structure);
- }
-
- function get_category_permastruct() {
- if (isset($this->category_structure)) {
- return $this->category_structure;
- }
-
- if (empty($this->permalink_structure)) {
- $this->category_structure = '';
- return false;
- }
-
- if (empty($this->category_base))
- $this->category_structure = $this->front . 'category/';
- else
- $this->category_structure = $this->category_base . '/';
-
- $this->category_structure .= '%category%';
-
- return $this->category_structure;
- }
-
- 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;
- }
-
- 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;
- }
-
- 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;
- }
-
- 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;
- }
-
- 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;
- }
-
- function add_rewrite_tag($tag, $pattern, $query) {
- // 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.
- $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;
- }
- }
-
- //the main WP_Rewrite function. generate the rules from permalink structure
- 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 ($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 = 'page/?([0-9]{1,})/?$';
-
- //build up an array of endpoint regexes to append => queries to append
- if ($endpoints) {
- $ep_query_append = array ();
- foreach ($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] . '&';
- }
-
- $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, '/');
- if ($walk_dirs) {
- $dirs = explode('/', $structure);
- } else {
- $dirs[] = $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 = $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;
- }
-
- //create query for /page/xx
- $pagematch = $match . $pageregex;
- $pagequery = $index . '?' . $query . '&paged=' . $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));
-
- //do endpoints
- if ($endpoints) {
- foreach ($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 we're creating rules for a permalink, do all the endpoints like attachments etc
- if ($post) {
- $post = true;
- //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...)
- //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...)
-
- //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);
-
- //do endpoints for attachments
- if ($endpoint) { foreach ($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));
- $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery));
- }
- } //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!
- }
-
- function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
- return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs);
- }
-
- /* rewrite_rules
- * Construct rewrite matches and queries from permalink structure.
- * Returns an associate array of matches and queries.
- */
- function rewrite_rules() {
- $rewrite = array();
-
- if (empty($this->permalink_structure)) {
- return $rewrite;
- }
-
- // robots.txt
- $robots_rewrite = array('robots.txt$' => $this->index . '?robots=1');
-
- //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');
-
- // 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);
-
- // Categories
- $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct(), EP_CATEGORIES);
- $category_rewrite = apply_filters('category_rewrite_rules', $category_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);
-
- // Put them together.
- $this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_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;
- }
-
- 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;
- }
-
- function mod_rewrite_rules() {
- if ( ! $this->using_permalinks()) {
- return '';
- }
-
- $site_root = parse_url(get_option('siteurl'));
- $site_root = trailingslashit($site_root['path']);
-
- $home_root = parse_url(get_option('home'));
- $home_root = trailingslashit($home_root['path']);
-
- $rules = "<IfModule mod_rewrite.c>\n";
- $rules .= "RewriteEngine On\n";
- $rules .= "RewriteBase $home_root\n";
-
- //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
- foreach ($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 ($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;
- }
-
- //Add a straight rewrite rule
- function add_rule($regex, $redirect) {
- //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 {
- $this->extra_rules[$regex] = $redirect;
- }
- }
-
- //add a rule that doesn't redirect to index.php
- 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)
- function add_endpoint($name, $places) {
- global $wp;
- $this->endpoints[] = array ( $places, $name );
- $wp->add_query_var($name);
- }
-
- function flush_rules() {
- generate_page_uri_index();
- delete_option('rewrite_rules');
- $this->wp_rewrite_rules();
- if ( function_exists('save_mod_rewrite_rules') )
- save_mod_rewrite_rules();
- }
-
- 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 . '/';
- }
- $this->category_base = get_option( 'category_base' );
- unset($this->category_structure);
- 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) == '/' ) ? true : false;
- }
-
- function set_permalink_structure($permalink_structure) {
- if ($permalink_structure != $this->permalink_structure) {
- update_option('permalink_structure', $permalink_structure);
- $this->init();
- }
- }
-
- function set_category_base($category_base) {
- if ($category_base != $this->category_base) {
- update_option('category_base', $category_base);
- $this->init();
- }
- }
-
- function WP_Rewrite() {
- $this->init();
- }
-}
-
-?>
+<?php
+
+/* WP_Rewrite API
+*******************************************************************************/
+
+//Add a straight rewrite rule
+function add_rewrite_rule($regex, $redirect) {
+ global $wp_rewrite;
+ $wp_rewrite->add_rule($regex, $redirect);
+}
+
+//Add a new tag (like %postname%)
+//warning: you must call this on init or earlier, otherwise the query var addition stuff won't work
+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 a new feed type like /atom1/
+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_action($hook, $function, 10, 1);
+ add_action($hook, $function, 10, 1);
+ return $hook;
+}
+
+define('EP_PERMALINK', 1 );
+define('EP_ATTACHMENT', 2 );
+define('EP_DATE', 4 );
+define('EP_YEAR', 8 );
+define('EP_MONTH', 16 );
+define('EP_DAY', 32 );
+define('EP_ROOT', 64 );
+define('EP_COMMENTS', 128 );
+define('EP_SEARCH', 256 );
+define('EP_CATEGORIES', 512 );
+define('EP_AUTHORS', 1024);
+define('EP_PAGES', 2048);
+//pseudo-places
+define('EP_NONE', 0 );
+define('EP_ALL', 4095);
+
+//and an endpoint, like /trackback/
+function add_rewrite_endpoint($name, $places) {
+ global $wp_rewrite;
+ $wp_rewrite->add_endpoint($name, $places);
+}
+
+// examine a url (supposedly from this blog) and try to
+// determine the post ID it represents.
+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
+ preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
+ $id = intval($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;
+
+ // $url cleanup by Mark Jaquith
+ // This fixes things like #anchors, ?query=strings, missing 'www.',
+ // added 'www.', or added 'index.php/' that will mess up our WP_Query
+ // and return a false negative
+
+ // 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(get_option('home'), '://www.') && false === strpos($url, '://www.') )
+ $url = str_replace('://', '://www.', $url);
+
+ // Strip 'www.' if it is present and shouldn't be
+ if ( false === strpos(get_option('home'), '://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, get_option('home')) ) {
+ // Chop off http://domain.com
+ $url = str_replace(get_option('home'), '', $url);
+ } else {
+ // Chop off /path/to/blog
+ $home_path = parse_url(get_option('home'));
+ $home_path = $home_path['path'];
+ $url = str_replace($home_path, '', $url);
+ }
+
+ // Trim leading and lagging slashes
+ $url = trim($url, '/');
+
+ $request = $url;
+
+ // Done with cleanup
+
+ // Look for matches.
+ $request_match = $request;
+ foreach ($rewrite as $match => $query) {
+ // If the requesting file is the anchor of the match, prepend it
+ // to the path info.
+ if ( (! empty($url)) && (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.
+ eval("\$query = \"$query\";");
+ $query = new WP_Query($query);
+ if ( $query->is_single || $query->is_page )
+ return $query->post->ID;
+ else
+ return 0;
+ }
+ }
+ return 0;
+}
+
+/* WP_Rewrite class
+*******************************************************************************/
+
+class WP_Rewrite {
+ var $permalink_structure;
+ var $use_trailing_slashes;
+ var $category_base;
+ var $category_structure;
+ var $author_base = 'author';
+ var $author_structure;
+ var $date_structure;
+ var $page_structure;
+ var $search_base = 'search';
+ var $search_structure;
+ var $comments_base = 'comments';
+ var $feed_base = 'feed';
+ var $comments_feed_structure;
+ var $feed_structure;
+ var $front;
+ var $root = '';
+ var $index = 'index.php';
+ var $matches = '';
+ var $rules;
+ var $extra_rules; //those not generated by the class, see add_rewrite_rule()
+ var $non_wp_rules; //rules that don't redirect to WP's index.php
+ var $endpoints;
+ var $use_verbose_rules = false;
+ var $rewritecode =
+ array(
+ '%year%',
+ '%monthnum%',
+ '%day%',
+ '%hour%',
+ '%minute%',
+ '%second%',
+ '%postname%',
+ '%post_id%',
+ '%category%',
+ '%author%',
+ '%pagename%',
+ '%search%'
+ );
+
+ 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]+)',
+ '(.+?)',
+ '([^/]+)',
+ '([^/]+)',
+ '(.+)'
+ );
+
+ var $queryreplace =
+ array (
+ 'year=',
+ 'monthnum=',
+ 'day=',
+ 'hour=',
+ 'minute=',
+ 'second=',
+ 'name=',
+ 'p=',
+ 'category_name=',
+ 'author_name=',
+ 'pagename=',
+ 's='
+ );
+
+ var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
+
+ function using_permalinks() {
+ if (empty($this->permalink_structure))
+ return false;
+ else
+ return true;
+ }
+
+ 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;
+ }
+
+ function using_mod_rewrite_permalinks() {
+ if ( $this->using_permalinks() && ! $this->using_index_permalinks())
+ return true;
+ else
+ return false;
+ }
+
+ function preg_index($number) {
+ $match_prefix = '$';
+ $match_suffix = '';
+
+ if (! empty($this->matches)) {
+ $match_prefix = '$' . $this->matches . '[';
+ $match_suffix = ']';
+ }
+
+ return "$match_prefix$number$match_suffix";
+ }
+
+ function page_rewrite_rules() {
+ $uris = get_option('page_uris');
+ $attachment_uris = get_option('page_attachment_uris');
+
+ $rewrite_rules = array();
+ $page_structure = $this->get_page_permastruct();
+ 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;
+ }
+
+ 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 ($tokens[0] as $token) {
+ if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
+ $front = $front . 'date/';
+ break;
+ }
+ $tok_index++;
+ }
+
+ $this->date_structure = $front . $date_endian;
+
+ return $this->date_structure;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ function get_day_permastruct() {
+ return $this->get_date_permastruct($this->permalink_structure);
+ }
+
+ function get_category_permastruct() {
+ if (isset($this->category_structure)) {
+ return $this->category_structure;
+ }
+
+ if (empty($this->permalink_structure)) {
+ $this->category_structure = '';
+ return false;
+ }
+
+ if (empty($this->category_base))
+ $this->category_structure = $this->front . 'category/';
+ else
+ $this->category_structure = $this->category_base . '/';
+
+ $this->category_structure .= '%category%';
+
+ return $this->category_structure;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ function add_rewrite_tag($tag, $pattern, $query) {
+ // 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.
+ $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;
+ }
+ }
+
+ //the main WP_Rewrite function. generate the rules from permalink structure
+ 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 ($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 = 'page/?([0-9]{1,})/?$';
+
+ //build up an array of endpoint regexes to append => queries to append
+ if ($endpoints) {
+ $ep_query_append = array ();
+ foreach ($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] . '&';
+ }
+
+ $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, '/');
+ if ($walk_dirs) {
+ $dirs = explode('/', $structure);
+ } else {
+ $dirs[] = $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 = $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;
+ }
+
+ //create query for /page/xx
+ $pagematch = $match . $pageregex;
+ $pagequery = $index . '?' . $query . '&paged=' . $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));
+
+ //do endpoints
+ if ($endpoints) {
+ foreach ($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 we're creating rules for a permalink, do all the endpoints like attachments etc
+ if ($post) {
+ $post = true;
+ //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...)
+ //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...)
+
+ //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);
+
+ //do endpoints for attachments
+ if ($endpoint) { foreach ($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));
+ $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery));
+ }
+ } //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!
+ }
+
+ function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
+ return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs);
+ }
+
+ /* rewrite_rules
+ * Construct rewrite matches and queries from permalink structure.
+ * Returns an associate array of matches and queries.
+ */
+ function rewrite_rules() {
+ $rewrite = array();
+
+ if (empty($this->permalink_structure)) {
+ return $rewrite;
+ }
+
+ // robots.txt
+ $robots_rewrite = array('robots.txt$' => $this->index . '?robots=1');
+
+ //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');
+
+ // 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);
+
+ // Categories
+ $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct(), EP_CATEGORIES);
+ $category_rewrite = apply_filters('category_rewrite_rules', $category_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);
+
+ // Put them together.
+ $this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_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;
+ }
+
+ 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;
+ }
+
+ function mod_rewrite_rules() {
+ if ( ! $this->using_permalinks()) {
+ return '';
+ }
+
+ $site_root = parse_url(get_option('siteurl'));
+ $site_root = trailingslashit($site_root['path']);
+
+ $home_root = parse_url(get_option('home'));
+ $home_root = trailingslashit($home_root['path']);
+
+ $rules = "<IfModule mod_rewrite.c>\n";
+ $rules .= "RewriteEngine On\n";
+ $rules .= "RewriteBase $home_root\n";
+
+ //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
+ foreach ($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 ($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;
+ }
+
+ //Add a straight rewrite rule
+ function add_rule($regex, $redirect) {
+ //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 {
+ $this->extra_rules[$regex] = $redirect;
+ }
+ }
+
+ //add a rule that doesn't redirect to index.php
+ 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)
+ function add_endpoint($name, $places) {
+ global $wp;
+ $this->endpoints[] = array ( $places, $name );
+ $wp->add_query_var($name);
+ }
+
+ function flush_rules() {
+ generate_page_uri_index();
+ delete_option('rewrite_rules');
+ $this->wp_rewrite_rules();
+ if ( function_exists('save_mod_rewrite_rules') )
+ save_mod_rewrite_rules();
+ }
+
+ 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 . '/';
+ }
+ $this->category_base = get_option('category_base');
+ unset($this->category_structure);
+ 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) == '/' ) ? true : false;
+ }
+
+ function set_permalink_structure($permalink_structure) {
+ if ($permalink_structure != $this->permalink_structure) {
+ update_option('permalink_structure', $permalink_structure);
+ $this->init();
+ }
+ }
+
+ function set_category_base($category_base) {
+ if ($category_base != $this->category_base) {
+ update_option('category_base', $category_base);
+ $this->init();
+ }
+ }
+
+ function WP_Rewrite() {
+ $this->init();
+ }
+}
+
+?>
diff --git a/wp-includes/rss.php b/wp-includes/rss.php
index da7bc1b..44005a7 100644
--- a/wp-includes/rss.php
+++ b/wp-includes/rss.php
@@ -815,8 +815,7 @@ function parse_w3cdtf ( $date_str ) {
else {
return -1;
}
-}
-
+ }
function wp_rss ($url, $num_items) {
//ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned.
$rss = fetch_rss($url);
@@ -833,7 +832,7 @@ function wp_rss ($url, $num_items) {
echo "</ul>";
}
else {
- echo 'An error has occurred the feed is probably down, try again later.';
+ echo "an error has occured the feed is probably down, try again later.";
}
}
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index bc180cf..8ee90aa 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -11,11 +11,8 @@ class WP_Scripts {
function default_scripts() {
$this->add( 'dbx', '/wp-includes/js/dbx.js', false, '2.05' );
-
$this->add( 'fat', '/wp-includes/js/fat.js', false, '1.0-RC1_3660' );
-
$this->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' );
-
$this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3958' );
$this->localize( 'quicktags', 'quicktagsL10n', array(
'quickLinks' => __('(Quick Links)'),
@@ -28,15 +25,11 @@ class WP_Scripts {
'enterImageURL' => __('Enter the URL of the image'),
'enterImageDescription' => __('Enter a description of the image')
) );
-
$this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
-
$this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070326' );
$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'), '20070225' );
-
- $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.1');
-
+ $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0-0');
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('prototype', 'sack'), '20070306');
$this->localize( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => apply_filters('autosave_interval', '120'),
@@ -45,7 +38,6 @@ class WP_Scripts {
'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
'savingText' => __('Saving Draft...')
) );
-
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306');
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
'defaultUrl' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
@@ -53,27 +45,21 @@ class WP_Scripts {
'strangeText' => __("Something strange happened. Try refreshing the page."),
'whoaText' => __("Slow down, I'm still sending your data!")
) );
-
$this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306' );
$this->localize( 'listman', 'listManL10n', array(
'jumpText' => __('Jump to new item'),
'delText' => __('Are you sure you want to delete this %thing%?')
) );
-
- $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.1-b2');
- $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.1-b2');
- $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.1-b2');
- $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.1-b2');
- $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.1-b2');
- $this->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.7.1-b2' );
- $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.1-b2');
- $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.1-b2');
-
+ $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0');
+ $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0');
+ $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.0');
+ $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.0');
+ $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.0');
+ $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.0');
+ $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.0');
$this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
-
$this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.2');
$this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2');
-
if ( is_admin() ) {
global $pagenow;
$man = false;
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 51513bc..e561e23 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -56,21 +56,6 @@ function get_template_directory_uri() {
}
function get_theme_data( $theme_file ) {
- $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 = implode( '', file( $theme_file ) );
$theme_data = str_replace ( '\r', '\n', $theme_data );
preg_match( '|Theme Name:(.*)|i', $theme_data, $theme_name );
@@ -79,28 +64,26 @@ function get_theme_data( $theme_file ) {
preg_match( '|Author:(.*)|i', $theme_data, $author_name );
preg_match( '|Author URI:(.*)|i', $theme_data, $author_uri );
preg_match( '|Template:(.*)|i', $theme_data, $template );
-
if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) )
- $version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
+ $version = trim( $version[1] );
else
- $version = '';
-
+ $version ='';
if ( preg_match('|Status:(.*)|i', $theme_data, $status) )
- $status = wp_kses( trim( $status[1] ), $themes_allowed_tags );
+ $status = trim($status[1]);
else
$status = 'publish';
-
- $name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags );
- $theme_uri = clean_url( trim( $theme_uri[1] ) );
- $description = wptexturize( wp_kses( trim( $description[1] ), $themes_allowed_tags ) );
- $template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
-
- $author_uri = clean_url( trim( $author_uri[1] ) );
-
- if ( empty( $author_uri[1] ) ) {
- $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
+
+ $description = wptexturize( trim( $description[1] ) );
+
+ $name = $theme_name[1];
+ $name = trim( $name );
+ $theme = $name;
+ $theme_uri = trim( $theme_uri[1] );
+
+ if ( '' == $author_uri[1] ) {
+ $author = trim( $author_name[1] );
} else {
- $author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) );
+ $author = '<a href="' . trim( $author_uri[1] ) . '" title="' . __('Visit author homepage') . '">' . trim( $author_name[1] ) . '</a>';
}
return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status );
diff --git a/wp-includes/user.php b/wp-includes/user.php
index ca4006b..f243fcc 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -56,7 +56,7 @@ function update_user_option( $user_id, $option_name, $newvalue, $global = false
function get_users_of_blog( $id = '' ) {
global $wpdb, $wpmuBaseTablePrefix;
if ( empty($id) )
- $id = (int) $wpdb->blogid;
+ $id = (int) $wpdb->blogid;
$users = $wpdb->get_results( "SELECT user_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 = '" . $wpmuBaseTablePrefix . $id . "_capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
return $users;
}
diff --git a/wp-includes/vars.php b/wp-includes/vars.php
index 010d174..0f749be 100644
--- a/wp-includes/vars.php
+++ b/wp-includes/vars.php
@@ -35,50 +35,4 @@ $is_IE = ( $is_macIE || $is_winIE );
$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;
$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false;
-$wp_header_to_desc = apply_filters( 'wp_header_to_desc_array', array(
- 100 => 'Continue',
- 101 => 'Switching Protocols',
-
- 200 => 'OK',
- 201 => 'Created',
- 202 => 'Accepted',
- 203 => 'Non-Authoritative Information',
- 204 => 'No Content',
- 205 => 'Reset Content',
- 206 => 'Partial Content',
-
- 300 => 'Multiple Choices',
- 301 => 'Moved Permanently',
- 302 => 'Found',
- 303 => 'See Other',
- 304 => 'Not Modified',
- 305 => 'Use Proxy',
- 307 => 'Temporary Redirect',
-
- 400 => 'Bad Request',
- 401 => 'Unauthorized',
- 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',
-
- 500 => 'Internal Server Error',
- 501 => 'Not Implemented',
- 502 => 'Bad Gateway',
- 503 => 'Service Unavailable',
- 504 => 'Gateway Timeout',
- 505 => 'HTTP Version Not Supported'
-) );
-
?>
diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php
index f4e2681..25027d3 100644
--- a/wp-includes/widgets.php
+++ b/wp-includes/widgets.php
@@ -332,12 +332,13 @@ function wp_widget_pages( $args ) {
$title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title'];
$sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];
+ $exclude = empty( $options['exclude'] ) ? '' : '&exclude=' . $options['exclude'];
if ( $sortby == 'menu_order' ) {
$sortby = 'menu_order, post_title';
}
- $out = wp_list_pages( 'title_li=&echo=0&sort_column=' . $sortby );
+ $out = wp_list_pages( 'title_li=&echo=0&sort_column=' . $sortby . $exclude );
if ( !empty( $out ) ) {
?>
@@ -363,27 +364,32 @@ function wp_widget_pages_control() {
} else {
$newoptions['sortby'] = 'menu_order';
}
+
+ $newoptions['exclude'] = strip_tags( stripslashes( $_POST['pages-exclude'] ) );
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_pages', $options);
}
$title = attribute_escape($options['title']);
+ $exclude = attribute_escape( $options['exclude'] );
?>
<p><label for="pages-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="pages-title" name="pages-title" type="text" value="<?php echo $title; ?>" /></label></p>
<p><label for="pages-sortby"><?php _e( 'Sort by:' ); ?>
<select name="pages-sortby" id="pages-sortby">
- <option value="post_title"<?php if ( $options['sortby'] == 'post_title' ) { ?> selected="selected"<?php } ?>><?php _e('Page title'); ?></option>
- <option value="menu_order"<?php if ( $options['sortby'] == 'menu_order' ) { ?> selected="selected"<?php } ?>><?php _e('Menu order'); ?></option>
- <option value="ID"<?php if ( $options['sortby'] == 'ID' ) { ?> selected="selected"<?php } ?>><?php _e( 'Page ID' ); ?></option>
+ <option value="post_title"<?php selected( $options['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>
+ <option value="menu_order"<?php selected( $options['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>
+ <option value="ID"<?php selected( $options['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
</select></label></p>
+ <p><label for="pages-exclude"><?php _e( 'Exclude:' ); ?> <input type="text" value="<?php echo $exclude; ?>" name="pages-exclude" id="pages-exclude" style="width: 180px;" /></label><br />
+ <small><?php _e( 'Page IDs, separated by commas.' ); ?></small></p>
<input type="hidden" id="pages-submit" name="pages-submit" value="1" />
<?php
}
function wp_widget_links($args) {
global $wp_db_version;
- extract($args);
+ extract($args, EXTR_SKIP);
if ( $wp_db_version < 3582 ) {
// This ONLY works with li/h2 sidebars.
get_links_list();
@@ -523,7 +529,7 @@ function wp_widget_text($args, $number = 1) {
extract($args);
$options = get_option('widget_text');
$title = $options[$number]['title'];
- $text = $options[$number]['text'];
+ $text = apply_filters( 'widget_text', $options[$number]['text'] );
?>
<?php echo $before_widget; ?>
<?php if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
@@ -799,7 +805,7 @@ function wp_widget_recent_comments_register() {
function wp_widget_rss($args, $number = 1) {
require_once(ABSPATH . WPINC . '/rss.php');
- extract($args);
+ extract($args, EXTR_SKIP);
$options = get_option('widget_rss');
if ( isset($options['error']) && $options['error'] )
return;
@@ -854,7 +860,7 @@ function wp_widget_rss($args, $number = 1) {
echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
}
} else {
- echo __('<li>An error has occured; the feed is probably down. Try again later.</li>');
+ echo '<li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li>';
}
?>
</ul>
@@ -956,7 +962,7 @@ function wp_widgets_init() {
$dims150 = array('height' => 150, 'width' => 300);
$class = array('classname' => 'widget_pages');
wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $class);
- wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control', $dims90);
+ wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control', $dims150);
$class['classname'] = 'widget_calendar';
wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $class);
wp_register_widget_control('calendar', __('Calendar'), 'wp_widget_calendar_control', $dims90);
diff --git a/wp-settings.php b/wp-settings.php
index e57af7e..e5d13c2 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -77,7 +77,7 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(
$mtime = $mtime[1] + $mtime[0];
$timeend = $mtime;
$timetotal = $timeend-$timestart;
- $r = number_format_i18n($timetotal, $precision);
+ $r = number_format($timetotal, $precision);
if ( $display )
echo $r;
return $r;
diff --git a/xmlrpc.php b/xmlrpc.php
index 1d48d83..a235e06 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -18,7 +18,7 @@ if ( isset($HTTP_RAW_POST_DATA) )
include('./wp-config.php');
if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
-header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
+header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
@@ -862,7 +862,7 @@ class wp_xmlrpc_server extends IXR_Server {
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);
+ 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.'));
@@ -988,12 +988,14 @@ class wp_xmlrpc_server extends IXR_Server {
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")));
+ 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")));
+ return(new IXR_Error(401, "You are not allowed to " .
+ "create pages as this user"));
}
break;
default:
@@ -1011,32 +1013,68 @@ class wp_xmlrpc_server extends IXR_Server {
$post_more = $content_struct['mt_text_more'];
if(isset($content_struct["mt_allow_comments"])) {
- switch((int) $content_struct["mt_allow_comments"]) {
- case 0:
- $comment_status = "closed";
- break;
- case 1:
- $comment_status = "open";
- break;
- default:
- $comment_status = get_option("default_comment_status");
- break;
+ 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:
+ $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"])) {
- 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;
+ if(!is_numeric($content_struct["mt_allow_pings"])) {
+ switch($content["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 . "\n<!--more-->\n" . $post_more;
@@ -1138,8 +1176,8 @@ class wp_xmlrpc_server extends IXR_Server {
return(new IXR_Error(404, __("Invalid post id.")));
}
- extract($postdata);
$this->escape($postdata);
+ extract($postdata, EXTR_SKIP);
// Let WordPress manage slug if none was provided.
$post_name = "";
@@ -1172,12 +1210,14 @@ class wp_xmlrpc_server extends IXR_Server {
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.")));
+ 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.")));
+ return(new IXR_Error(401, "You are not allowed to " .
+ "change the page author as this user."));
}
break;
default:
@@ -1187,15 +1227,61 @@ class wp_xmlrpc_server extends IXR_Server {
$post_author = $content_struct["wp_author_id"];
}
- // Only set ping_status if it was provided.
+ 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:
+ $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"])) {
- switch((int) $content_struct["mt_allow_pings"]) {
- case 0:
- $ping_status = "closed";
- break;
- case 1:
- $ping_status = "open";
- break;
+ if(!is_numeric($content_struct["mt_allow_pings"])) {
+ switch($content["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;
+ }
}
}
@@ -1230,10 +1316,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( is_array($to_ping) )
$to_ping = implode(' ', $to_ping);
- if(isset($content_struct["mt_allow_comments"])) {
- $comment_status = (int) $content_struct["mt_allow_comments"];
- }
-
// Do some timestamp voodoo
$dateCreatedd = $content_struct['dateCreated'];
if (!empty($dateCreatedd)) {
@@ -1446,6 +1528,21 @@ class wp_xmlrpc_server extends IXR_Server {
$type = $data['type'];
$bits = $data['bits'];
+ logIO('O', '(MW) Received '.strlen($bits).' bytes');
+
+ if ( !$this->login_pass_ok($user_login, $user_pass) )
+ return $this->error;
+
+ set_current_user(0, $user_login);
+ 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("
@@ -1464,24 +1561,9 @@ class wp_xmlrpc_server extends IXR_Server {
$name = "wpid{$old_file->ID}-{$filename}";
}
- logIO('O', '(MW) Received '.strlen($bits).' bytes');
-
- if ( !$this->login_pass_ok($user_login, $user_pass) )
- return $this->error;
-
- set_current_user(0, $user_login);
- 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);
-
$upload = wp_upload_bits($name, $type, $bits, $overwrite);
if ( ! empty($upload['error']) ) {
- $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);
+ $errorString = 'Could not write file ' . $name . ' (' . $upload['error'] . ')';
logIO('O', '(MW) ' . $errorString);
return new IXR_Error(500, $errorString);
}
@@ -1792,7 +1874,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
} 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\'t exist, or it is not a pingback-enabled resource.'));
+ return new IXR_Error(33, 'The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
}
$post_ID = (int) $post_ID;
@@ -1802,14 +1884,14 @@ class wp_xmlrpc_server extends IXR_Server {
$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\'t exist, or it is not a pingback-enabled resource.'));
+ return new IXR_Error(33, 'The specified target URL cannot be used as a target. It either doesn\'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 ( 'closed' == $post->ping_status )
- return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'));
+ return new IXR_Error(33, 'The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
// Let's check that the remote site didn't already pingback this entry
$result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");
@@ -1891,7 +1973,7 @@ class wp_xmlrpc_server extends IXR_Server {
$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);
+ return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
}
@@ -1909,7 +1991,7 @@ class wp_xmlrpc_server extends IXR_Server {
$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\'t exist, or it is not a pingback-enabled resource.'));
+ return new IXR_Error(33, 'The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
}
$actual_post = wp_get_single_post($post_ID, ARRAY_A);