summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php4
-rw-r--r--wp-admin/admin-ajax.php2
-rw-r--r--wp-admin/admin-db.php50
-rw-r--r--wp-admin/admin-functions.php1610
-rw-r--r--wp-admin/admin-header.php2
-rw-r--r--wp-admin/bookmarklet.php20
-rw-r--r--wp-admin/categories.php25
-rw-r--r--wp-admin/comment.php2
-rw-r--r--wp-admin/custom-fields.js4
-rw-r--r--wp-admin/dbx-admin-key-js.php2
-rw-r--r--wp-admin/edit-category-form.php1
-rw-r--r--wp-admin/edit-comments.php94
-rw-r--r--wp-admin/edit-form-advanced.php13
-rw-r--r--wp-admin/edit-form-comment.php4
-rw-r--r--wp-admin/edit-form.php12
-rw-r--r--wp-admin/edit-link-form.php6
-rw-r--r--wp-admin/edit-page-form.php14
-rw-r--r--wp-admin/edit-pages.php16
-rw-r--r--wp-admin/edit.php66
-rw-r--r--wp-admin/export.php55
-rw-r--r--wp-admin/import/blogger.php2
-rw-r--r--wp-admin/import/blogware.php16
-rw-r--r--wp-admin/import/dotclear.php137
-rw-r--r--wp-admin/import/greymatter.php14
-rw-r--r--wp-admin/import/mt.php2
-rw-r--r--wp-admin/import/textpattern.php192
-rw-r--r--wp-admin/import/wordpress.php2
-rw-r--r--wp-admin/index-extra.php67
-rw-r--r--wp-admin/install-helper.php172
-rw-r--r--wp-admin/link-add.php8
-rw-r--r--wp-admin/link-import.php10
-rw-r--r--wp-admin/link-manager.php23
-rw-r--r--wp-admin/link-parse-opml.php44
-rw-r--r--wp-admin/link.php10
-rw-r--r--wp-admin/menu-header.php17
-rw-r--r--wp-admin/menu.php11
-rw-r--r--wp-admin/moderation.php36
-rw-r--r--wp-admin/options-misc.php10
-rw-r--r--wp-admin/options-permalink.php2
-rw-r--r--wp-admin/options-reading.php8
-rw-r--r--wp-admin/options-writing.php8
-rw-r--r--wp-admin/plugin-editor.php46
-rw-r--r--wp-admin/plugins.php15
-rw-r--r--wp-admin/post.php4
-rw-r--r--wp-admin/profile.php19
-rw-r--r--wp-admin/setup-config.php152
-rw-r--r--wp-admin/sidebar.php16
-rw-r--r--wp-admin/templates.php50
-rw-r--r--wp-admin/theme-editor.php34
-rw-r--r--wp-admin/themes.php8
-rw-r--r--wp-admin/update-links.php6
-rw-r--r--wp-admin/upgrade-functions.php168
-rw-r--r--wp-admin/upgrade-schema.php2
-rw-r--r--wp-admin/upgrade.php2
-rw-r--r--wp-admin/upload-functions.php19
-rw-r--r--wp-admin/upload-js.php35
-rw-r--r--wp-admin/upload-rtl.css14
-rw-r--r--wp-admin/upload.css47
-rw-r--r--wp-admin/upload.php8
-rw-r--r--wp-admin/user-edit.php26
-rw-r--r--wp-admin/users.php25
-rw-r--r--wp-admin/wp-admin.css15
-rw-r--r--wp-admin/xfn.js8
-rw-r--r--wp-atom.php18
-rw-r--r--wp-commentsrss2.php15
-rw-r--r--wp-content/themes/classic/comments-popup.php8
-rw-r--r--wp-content/themes/classic/comments.php4
-rw-r--r--wp-content/themes/classic/header.php2
-rw-r--r--wp-content/themes/classic/sidebar.php6
-rw-r--r--wp-content/themes/default/archives.php12
-rw-r--r--wp-content/themes/default/comments-popup.php8
-rw-r--r--wp-content/themes/default/comments.php24
-rw-r--r--wp-content/themes/default/header.php6
-rw-r--r--wp-content/themes/default/page.php4
-rw-r--r--wp-content/themes/default/sidebar.php4
-rw-r--r--wp-content/themes/default/single.php6
-rw-r--r--wp-cron.php10
-rw-r--r--wp-feed.php4
-rw-r--r--wp-includes/author-template.php2
-rw-r--r--wp-includes/bookmark-template.php12
-rw-r--r--wp-includes/bookmark.php16
-rw-r--r--wp-includes/cache.php10
-rw-r--r--wp-includes/capabilities.php43
-rw-r--r--wp-includes/category-template.php8
-rw-r--r--wp-includes/category.php31
-rw-r--r--wp-includes/classes.php115
-rw-r--r--wp-includes/comment-template.php45
-rw-r--r--wp-includes/comment.php42
-rw-r--r--wp-includes/compat.php66
-rw-r--r--wp-includes/deprecated.php142
-rw-r--r--wp-includes/feed.php4
-rw-r--r--wp-includes/formatting.php165
-rw-r--r--wp-includes/functions.php60
-rw-r--r--wp-includes/general-template.php71
-rw-r--r--wp-includes/js/autosave.js.php12
-rw-r--r--wp-includes/js/list-manipulation-js.php18
-rw-r--r--wp-includes/js/tinymce/license.txt255
-rw-r--r--wp-includes/js/tinymce/plugins/autosave/editor_plugin.js8
-rw-r--r--wp-includes/js/tinymce/plugins/directionality/editor_plugin.js8
-rw-r--r--wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js10
-rw-r--r--wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js4
-rw-r--r--wp-includes/js/tinymce/plugins/paste/editor_plugin.js387
-rw-r--r--wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js4
-rw-r--r--wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js6
-rw-r--r--wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js2
-rw-r--r--wp-includes/js/tinymce/themes/advanced/charmap.htm2
-rw-r--r--wp-includes/js/tinymce/themes/advanced/color_picker.htm2
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/editor_content.css5
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/editor_popup.css4
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/editor_ui.css423
-rw-r--r--wp-includes/js/tinymce/themes/advanced/editor_template.js211
-rw-r--r--wp-includes/js/tinymce/themes/advanced/editor_template_src.js0
-rw-r--r--wp-includes/js/tinymce/themes/advanced/images/backcolor.gifbin174 -> 359 bytes
-rw-r--r--wp-includes/js/tinymce/themes/advanced/images/buttons.gifbin8399 -> 5662 bytes
-rw-r--r--wp-includes/js/tinymce/themes/advanced/images/forecolor.gifbin272 -> 342 bytes
-rw-r--r--wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js30
-rw-r--r--wp-includes/js/tinymce/themes/advanced/langs/en.js8
-rw-r--r--wp-includes/js/tinymce/tiny_mce.js2093
-rw-r--r--wp-includes/js/tinymce/tiny_mce_popup.js446
-rw-r--r--wp-includes/js/tinymce/utils/form_utils.js29
-rw-r--r--wp-includes/js/tinymce/utils/mclayer.js6
-rw-r--r--wp-includes/js/tinymce/utils/mctabs.js4
-rw-r--r--wp-includes/js/tinymce/utils/validate.js235
-rw-r--r--wp-includes/js/wp-ajax-js.php5
-rw-r--r--wp-includes/l10n.php2
-rw-r--r--wp-includes/link-template.php72
-rw-r--r--wp-includes/pluggable.php23
-rw-r--r--wp-includes/post.php160
-rw-r--r--wp-includes/query.php87
-rw-r--r--wp-includes/registration.php4
-rw-r--r--wp-includes/rewrite.php72
-rw-r--r--wp-includes/script-loader.php21
-rw-r--r--wp-includes/theme.php149
-rw-r--r--wp-includes/user.php2
-rw-r--r--wp-includes/wp-db.php2
-rw-r--r--wp-includes/wpmu-functions.php15
-rw-r--r--wp-links-opml.php12
-rw-r--r--wp-login.php2
-rw-r--r--wp-rss.php4
-rw-r--r--wp-rss2.php6
-rw-r--r--wp-settings.php13
-rw-r--r--wp-trackback.php4
-rw-r--r--xmlrpc.php619
143 files changed, 5726 insertions, 4235 deletions
diff --git a/index.php b/index.php
index 3e3db40..e5076a8 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,5 @@
-<?php
+<?php
/* Short and sweet */
define('WP_USE_THEMES', true);
require('./wp-blog-header.php');
-?> \ No newline at end of file
+?>
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 4e27900..cc93b16 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -128,7 +128,7 @@ case 'add-category' : // On the Fly
break;
case 'add-cat' : // From Manage->Categories
if ( !current_user_can( 'manage_categories' ) )
- die('-1');
+ die('-1');
if ( !$cat = wp_insert_category( $_POST ) )
die('0');
if ( !$cat = get_category( $cat ) )
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
index b41891f..ea6e60d 100644
--- a/wp-admin/admin-db.php
+++ b/wp-admin/admin-db.php
@@ -48,7 +48,7 @@ function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
if ( ! $user->has_cap('edit_others_posts') ) {
if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
return array($user->id);
- else
+ else
return false;
}
@@ -157,6 +157,9 @@ function wp_update_category($catarr) {
$cat_ID = (int) $catarr['cat_ID'];
+ if( $cat_ID == $catarr['category_parent'] )
+ return false;
+
// First, get all of the original fields
$category = get_category($cat_ID, ARRAY_A);
@@ -201,7 +204,7 @@ function wp_delete_category($cat_ID) {
$cats = array($default_cat);
else
$cats = array_diff($cats, array($cat_ID));
- wp_set_post_categories($post_id, $cats);
+ wp_set_post_categories($post_id, $cats);
}
$default_link_cat = get_option('default_link_category');
@@ -212,9 +215,9 @@ function wp_delete_category($cat_ID) {
$cats = array($default_link_cat);
else
$cats = array_diff($cats, array($cat_ID));
- wp_set_link_cats($link_id, $cats);
+ wp_set_link_cats($link_id, $cats);
}
-
+
wp_cache_delete($cat_ID, 'category');
wp_cache_delete('all_category_ids', 'category');
@@ -287,9 +290,9 @@ function wp_delete_user($id, $reassign = 'novalue') {
function wp_revoke_user($id) {
$id = (int) $id;
-
+
$user = new WP_User($id);
- $user->remove_all_caps();
+ $user->remove_all_caps();
}
function wp_insert_link($linkdata) {
@@ -387,15 +390,15 @@ function wp_update_link($linkdata) {
$link = add_magic_quotes($link);
// Passed link category list overwrites existing category list if not empty.
- if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
+ if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
&& 0 != count($linkdata['link_category']) )
- $link_cats = $linkdata['link_category'];
- else
- $link_cats = $link['link_category'];
+ $link_cats = $linkdata['link_category'];
+ else
+ $link_cats = $link['link_category'];
// Merge old and new fields with new fields overwriting old ones.
$linkdata = array_merge($link, $linkdata);
- $linkdata['link_category'] = $link_cats;
+ $linkdata['link_category'] = $link_cats;
return wp_insert_link($linkdata);
}
@@ -404,7 +407,7 @@ function wp_delete_link($link_id) {
global $wpdb;
do_action('delete_link', $link_id);
-
+
$categories = wp_get_link_cats($link_id);
if( is_array( $categories ) ) {
foreach ( $categories as $category ) {
@@ -420,9 +423,9 @@ function wp_delete_link($link_id) {
function wp_get_link_cats($link_ID = 0) {
global $wpdb;
- $sql = "SELECT category_id
- FROM $wpdb->link2cat
- WHERE link_id = $link_ID
+ $sql = "SELECT category_id
+ FROM $wpdb->link2cat
+ WHERE link_id = $link_ID
ORDER BY category_id";
$result = $wpdb->get_col($sql);
@@ -443,8 +446,8 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
// First the old categories
$old_categories = $wpdb->get_col("
- SELECT category_id
- FROM $wpdb->link2cat
+ SELECT category_id
+ FROM $wpdb->link2cat
WHERE link_id = $link_ID");
if (!$old_categories) {
@@ -459,9 +462,9 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
if ($delete_cats) {
foreach ($delete_cats as $del) {
$wpdb->query("
- DELETE FROM $wpdb->link2cat
- WHERE category_id = $del
- AND link_id = $link_ID
+ DELETE FROM $wpdb->link2cat
+ WHERE category_id = $del
+ AND link_id = $link_ID
");
}
}
@@ -472,18 +475,21 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
if ($add_cats) {
foreach ($add_cats as $new_cat) {
$wpdb->query("
- INSERT INTO $wpdb->link2cat (link_id, category_id)
+ INSERT INTO $wpdb->link2cat (link_id, category_id)
VALUES ($link_ID, $new_cat)");
}
}
-
+
// Update category counts.
$all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
foreach ( $all_affected_cats as $cat_id ) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
$wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
wp_cache_delete($cat_id, 'category');
+ do_action('edit_category', $cat_id);
}
+
+ do_action('edit_link', $link_ID);
} // wp_set_link_cats()
function post_exists($title, $content = '', $post_date = '') {
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 0f80efd..8da7ff0 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -2,7 +2,7 @@
function write_post() {
$result = wp_write_post();
- if( is_wp_error($result) )
+ if( is_wp_error( $result ) )
wp_die( $result->get_error_message() );
else
return $result;
@@ -13,11 +13,11 @@ function wp_write_post() {
global $user_ID;
if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can('edit_pages') )
- return new WP_Error('edit_pages', __('You are not allowed to create pages on this blog.'));
+ if ( !current_user_can( 'edit_pages' ) )
+ return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) );
} else {
- if ( !current_user_can('edit_posts') )
- return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this blog.'));
+ if ( !current_user_can( 'edit_posts' ) )
+ return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) );
}
// Rename.
@@ -26,10 +26,10 @@ function wp_write_post() {
$_POST['post_parent'] = $_POST['parent_id'];
$_POST['to_ping'] = $_POST['trackback_url'];
- if (!empty ($_POST['post_author_override'])) {
+ if (!empty ( $_POST['post_author_override'] ) ) {
$_POST['post_author'] = (int) $_POST['post_author_override'];
} else {
- if (!empty ($_POST['post_author'])) {
+ if (!empty ( $_POST['post_author'] ) ) {
$_POST['post_author'] = (int) $_POST['post_author'];
} else {
$_POST['post_author'] = (int) $_POST['user_ID'];
@@ -37,118 +37,118 @@ function wp_write_post() {
}
- if ($_POST['post_author'] != $_POST['user_ID']) {
+ if ( $_POST['post_author'] != $_POST['user_ID'] ) {
if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can('edit_others_pages') )
- return new WP_Error('edit_others_pages', __('You cannot create pages as this user.'));
+ if ( !current_user_can( 'edit_others_pages' ) )
+ return new WP_Error( 'edit_others_pages', __( 'You cannot create pages as this user.' ) );
} else {
- if ( !current_user_can('edit_others_posts') )
- return new WP_Error('edit_others_posts', __('You cannot post as this user.'));
+ if ( !current_user_can( 'edit_others_posts' ) )
+ return new WP_Error( 'edit_others_posts', __( 'You cannot post as this user.' ) );
}
}
// What to do based on which button they pressed
- if ('' != $_POST['saveasdraft'])
+ if ('' != $_POST['saveasdraft'] )
$_POST['post_status'] = 'draft';
- if ('' != $_POST['saveasprivate'])
+ if ('' != $_POST['saveasprivate'] )
$_POST['post_status'] = 'private';
- if ('' != $_POST['publish'])
+ if ('' != $_POST['publish'] )
$_POST['post_status'] = 'publish';
- if ('' != $_POST['advanced'])
+ if ('' != $_POST['advanced'] )
$_POST['post_status'] = 'draft';
if ( 'page' == $_POST['post_type'] ) {
- if ('publish' == $_POST['post_status'] && !current_user_can('publish_pages'))
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
$_POST['post_status'] = 'draft';
} else {
- if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) )
$_POST['post_status'] = 'draft';
}
- if (!isset ($_POST['comment_status']))
+ if (!isset( $_POST['comment_status'] ))
$_POST['comment_status'] = 'closed';
- if (!isset ($_POST['ping_status']))
+ if (!isset( $_POST['ping_status'] ))
$_POST['ping_status'] = 'closed';
- if (!empty ($_POST['edit_date'])) {
+ if (!empty ( $_POST['edit_date'] ) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
$jj = $_POST['jj'];
$hh = $_POST['hh'];
$mn = $_POST['mn'];
$ss = $_POST['ss'];
- $jj = ($jj > 31) ? 31 : $jj;
- $hh = ($hh > 23) ? $hh -24 : $hh;
- $mn = ($mn > 59) ? $mn -60 : $mn;
- $ss = ($ss > 59) ? $ss -60 : $ss;
- $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
- $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']);
+ $jj = ($jj > 31 ) ? 31 : $jj;
+ $hh = ($hh > 23 ) ? $hh -24 : $hh;
+ $mn = ($mn > 59 ) ? $mn -60 : $mn;
+ $ss = ($ss > 59 ) ? $ss -60 : $ss;
+ $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
+ $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] );
}
// Create the post.
- $post_ID = wp_insert_post($_POST);
- add_meta($post_ID);
+ $post_ID = wp_insert_post( $_POST);
+ add_meta( $post_ID );
// Reunite any orphaned attachments with their parent
if ( $_POST['temp_ID'] )
- relocate_children($_POST['temp_ID'], $post_ID);
+ relocate_children( $_POST['temp_ID'], $post_ID );
// Now that we have an ID we can fix any attachment anchor hrefs
- fix_attachment_links($post_ID);
+ fix_attachment_links( $post_ID );
return $post_ID;
}
// Move child posts to a new parent
-function relocate_children($old_ID, $new_ID) {
+function relocate_children( $old_ID, $new_ID ) {
global $wpdb;
$old_ID = (int) $old_ID;
$new_ID = (int) $new_ID;
- return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
+ return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" );
}
// Replace hrefs of attachment anchors with up-to-date permalinks.
-function fix_attachment_links($post_ID) {
+function fix_attachment_links( $post_ID ) {
global $wp_rewrite;
- $post = & get_post($post_ID, ARRAY_A);
+ $post = & get_post( $post_ID, ARRAY_A );
- $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
+ $search = "#<a[^>]+rel=('|\" )[^'\"]*attachment[^>]*>#ie";
// See if we have any rel="attachment" links
- if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )
+ if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) )
return;
$i = 0;
- $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
+ $search = "#[\s]+rel=(\"|' )(.*? )wp-att-(\d+ )\\1#i";
foreach ( $anchor_matches[0] as $anchor ) {
- if ( 0 == preg_match($search, $anchor, $id_matches) )
+ if ( 0 == preg_match( $search, $anchor, $id_matches ) )
continue;
$id = $id_matches[3];
// While we have the attachment ID, let's adopt any orphans.
- $attachment = & get_post($id, ARRAY_A);
- if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) {
+ $attachment = & get_post( $id, ARRAY_A );
+ if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) {
$attachment['post_parent'] = $post_ID;
// Escape data pulled from DB.
- $attachment = add_magic_quotes($attachment);
- wp_update_post($attachment);
+ $attachment = add_magic_quotes( $attachment);
+ wp_update_post( $attachment);
}
$post_search[$i] = $anchor;
- $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);
+ $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor );
++$i;
}
- $post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']);
+ $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] );
// Escape data pulled from DB.
- $post = add_magic_quotes($post);
+ $post = add_magic_quotes( $post);
- return wp_update_post($post);
+ return wp_update_post( $post);
}
// Update an existing post with values provided in $_POST.
@@ -158,11 +158,11 @@ function edit_post() {
$post_ID = (int) $_POST['post_ID'];
if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can('edit_page', $post_ID) )
- wp_die(__('You are not allowed to edit this page.'));
+ if ( !current_user_can( 'edit_page', $post_ID ) )
+ wp_die( __('You are not allowed to edit this page.' ));
} else {
- if ( !current_user_can('edit_post', $post_ID) )
- wp_die(__('You are not allowed to edit this post.'));
+ if ( !current_user_can( 'edit_post', $post_ID ) )
+ wp_die( __('You are not allowed to edit this post.' ));
}
// Rename.
@@ -172,82 +172,82 @@ function edit_post() {
$_POST['post_parent'] = $_POST['parent_id'];
$_POST['to_ping'] = $_POST['trackback_url'];
- if (!empty ($_POST['post_author_override'])) {
+ if (!empty ( $_POST['post_author_override'] ) ) {
$_POST['post_author'] = (int) $_POST['post_author_override'];
} else
- if (!empty ($_POST['post_author'])) {
+ if (!empty ( $_POST['post_author'] ) ) {
$_POST['post_author'] = (int) $_POST['post_author'];
} else {
$_POST['post_author'] = (int) $_POST['user_ID'];
}
- if ($_POST['post_author'] != $_POST['user_ID']) {
+ if ( $_POST['post_author'] != $_POST['user_ID'] ) {
if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can('edit_others_pages') )
- wp_die(__('You cannot edit pages as this user.'));
+ if ( !current_user_can( 'edit_others_pages' ) )
+ wp_die( __('You cannot edit pages as this user.' ));
} else {
- if ( !current_user_can('edit_others_posts') )
- wp_die(__('You cannot edit posts as this user.'));
+ if ( !current_user_can( 'edit_others_posts' ) )
+ wp_die( __('You cannot edit posts as this user.' ));
}
}
// What to do based on which button they pressed
- if ('' != $_POST['saveasdraft'])
+ if ('' != $_POST['saveasdraft'] )
$_POST['post_status'] = 'draft';
- if ('' != $_POST['saveasprivate'])
+ if ('' != $_POST['saveasprivate'] )
$_POST['post_status'] = 'private';
- if ('' != $_POST['publish'])
+ if ('' != $_POST['publish'] )
$_POST['post_status'] = 'publish';
- if ('' != $_POST['advanced'])
+ if ('' != $_POST['advanced'] )
$_POST['post_status'] = 'draft';
if ( 'page' == $_POST['post_type'] ) {
- if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_pages'))
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' ))
$_POST['post_status'] = 'draft';
} else {
- if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_posts'))
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' ))
$_POST['post_status'] = 'draft';
}
- if (!isset ($_POST['comment_status']))
+ if (!isset( $_POST['comment_status'] ))
$_POST['comment_status'] = 'closed';
- if (!isset ($_POST['ping_status']))
+ if (!isset( $_POST['ping_status'] ))
$_POST['ping_status'] = 'closed';
- if (!empty ($_POST['edit_date'])) {
+ if (!empty ( $_POST['edit_date'] ) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
$jj = $_POST['jj'];
$hh = $_POST['hh'];
$mn = $_POST['mn'];
$ss = $_POST['ss'];
- $jj = ($jj > 31) ? 31 : $jj;
- $hh = ($hh > 23) ? $hh -24 : $hh;
- $mn = ($mn > 59) ? $mn -60 : $mn;
- $ss = ($ss > 59) ? $ss -60 : $ss;
+ $jj = ($jj > 31 ) ? 31 : $jj;
+ $hh = ($hh > 23 ) ? $hh -24 : $hh;
+ $mn = ($mn > 59 ) ? $mn -60 : $mn;
+ $ss = ($ss > 59 ) ? $ss -60 : $ss;
$_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
- $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss");
+ $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" );
}
// Meta Stuff
- if ($_POST['meta']) {
- foreach ($_POST['meta'] as $key => $value)
- update_meta($key, $value['key'], $value['value']);
+ if ( $_POST['meta'] ) {
+ foreach ( $_POST['meta'] as $key => $value )
+ update_meta( $key, $value['key'], $value['value'] );
}
- if ($_POST['deletemeta']) {
- foreach ($_POST['deletemeta'] as $key => $value)
- delete_meta($key);
+ if ( $_POST['deletemeta'] ) {
+ foreach ( $_POST['deletemeta'] as $key => $value )
+ delete_meta( $key );
}
- add_meta($post_ID);
+ add_meta( $post_ID );
- wp_update_post($_POST);
+ wp_update_post( $_POST);
// Now that we have an ID we can fix any attachment anchor hrefs
- fix_attachment_links($post_ID);
+ fix_attachment_links( $post_ID );
return $post_ID;
}
@@ -258,8 +258,8 @@ function edit_comment() {
$comment_ID = (int) $_POST['comment_ID'];
$comment_post_ID = (int) $_POST['comment_post_ID'];
- if (!current_user_can('edit_post', $comment_post_ID))
- wp_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
+ if (!current_user_can( 'edit_post', $comment_post_ID ))
+ wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' ));
$_POST['comment_author'] = $_POST['newcomment_author'];
$_POST['comment_author_email'] = $_POST['newcomment_author_email'];
@@ -268,78 +268,78 @@ function edit_comment() {
$_POST['comment_content'] = $_POST['content'];
$_POST['comment_ID'] = (int) $_POST['comment_ID'];
- if (!empty ($_POST['edit_date'])) {
+ if (!empty ( $_POST['edit_date'] ) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
$jj = $_POST['jj'];
$hh = $_POST['hh'];
$mn = $_POST['mn'];
$ss = $_POST['ss'];
- $jj = ($jj > 31) ? 31 : $jj;
- $hh = ($hh > 23) ? $hh -24 : $hh;
- $mn = ($mn > 59) ? $mn -60 : $mn;
- $ss = ($ss > 59) ? $ss -60 : $ss;
+ $jj = ($jj > 31 ) ? 31 : $jj;
+ $hh = ($hh > 23 ) ? $hh -24 : $hh;
+ $mn = ($mn > 59 ) ? $mn -60 : $mn;
+ $ss = ($ss > 59 ) ? $ss -60 : $ss;
$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
}
- wp_update_comment($_POST);
+ wp_update_comment( $_POST);
}
// Get an existing post and format it for editing.
-function get_post_to_edit($id) {
+function get_post_to_edit( $id ) {
- $post = get_post($id);
+ $post = get_post( $id );
- $post->post_content = format_to_edit($post->post_content, user_can_richedit());
- $post->post_content = apply_filters('content_edit_pre', $post->post_content);
+ $post->post_content = format_to_edit( $post->post_content, user_can_richedit() );
+ $post->post_content = apply_filters( 'content_edit_pre', $post->post_content);
- $post->post_excerpt = format_to_edit($post->post_excerpt);
- $post->post_excerpt = apply_filters('excerpt_edit_pre', $post->post_excerpt);
+ $post->post_excerpt = format_to_edit( $post->post_excerpt);
+ $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt);
- $post->post_title = format_to_edit($post->post_title);
- $post->post_title = apply_filters('title_edit_pre', $post->post_title);
+ $post->post_title = format_to_edit( $post->post_title );
+ $post->post_title = apply_filters( 'title_edit_pre', $post->post_title );
- $post->post_password = format_to_edit($post->post_password);
+ $post->post_password = format_to_edit( $post->post_password );
- if ($post->post_type == 'page')
- $post->page_template = get_post_meta($id, '_wp_page_template', true);
+ if ( $post->post_type == 'page' )
+ $post->page_template = get_post_meta( $id, '_wp_page_template', true );
return $post;
}
// Default post information to use when populating the "Write Post" form.
function get_default_post_to_edit() {
- if ( !empty($_REQUEST['post_title']) )
- $post_title = wp_specialchars(stripslashes($_REQUEST['post_title']));
- else if ( !empty($_REQUEST['popuptitle']) ) {
- $post_title = wp_specialchars(stripslashes($_REQUEST['popuptitle']));
- $post_title = funky_javascript_fix($post_title);
+ if ( !empty( $_REQUEST['post_title'] ) )
+ $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] ));
+ else if ( !empty( $_REQUEST['popuptitle'] ) ) {
+ $post_title = wp_specialchars( stripslashes( $_REQUEST['popuptitle'] ));
+ $post_title = funky_javascript_fix( $post_title );
} else {
$post_title = '';
}
- if ( !empty($_REQUEST['content']) )
- $post_content = wp_specialchars(stripslashes($_REQUEST['content']));
- else if ( !empty($post_title) ) {
- $text = wp_specialchars(stripslashes(urldecode($_REQUEST['text'])));
- $text = funky_javascript_fix($text);
- $popupurl = wp_specialchars($_REQUEST['popupurl']);
+ if ( !empty( $_REQUEST['content'] ) )
+ $post_content = wp_specialchars( stripslashes( $_REQUEST['content'] ));
+ else if ( !empty( $post_title ) ) {
+ $text = wp_specialchars( stripslashes( urldecode( $_REQUEST['text'] ) ) );
+ $text = funky_javascript_fix( $text);
+ $popupurl = wp_specialchars( $_REQUEST['popupurl'] );
$post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
}
- if ( !empty($_REQUEST['excerpt']) )
- $post_excerpt = wp_specialchars(stripslashes($_REQUEST['excerpt']));
+ if ( !empty( $_REQUEST['excerpt'] ) )
+ $post_excerpt = wp_specialchars( stripslashes( $_REQUEST['excerpt'] ));
else
$post_excerpt = '';
$post->post_status = 'draft';
- $post->comment_status = get_option('default_comment_status');
- $post->ping_status = get_option('default_ping_status');
- $post->post_pingback = get_option('default_pingback_flag');
- $post->post_category = get_option('default_category');
- $post->post_content = apply_filters('default_content', $post_content);
- $post->post_title = apply_filters('default_title', $post_title);
- $post->post_excerpt = apply_filters('default_excerpt', $post_excerpt);
+ $post->comment_status = get_option( 'default_comment_status' );
+ $post->ping_status = get_option( 'default_ping_status' );
+ $post->post_pingback = get_option( 'default_pingback_flag' );
+ $post->post_category = get_option( 'default_category' );
+ $post->post_content = apply_filters( 'default_content', $post_content);
+ $post->post_title = apply_filters( 'default_title', $post_title );
+ $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
$post->page_template = 'default';
$post->post_parent = 0;
$post->menu_order = 0;
@@ -347,21 +347,21 @@ function get_default_post_to_edit() {
return $post;
}
-function get_comment_to_edit($id) {
- $comment = get_comment($id);
+function get_comment_to_edit( $id ) {
+ $comment = get_comment( $id );
- $comment->comment_content = format_to_edit($comment->comment_content, user_can_richedit());
- $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
+ $comment->comment_content = format_to_edit( $comment->comment_content, user_can_richedit() );
+ $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);
- $comment->comment_author = format_to_edit($comment->comment_author);
- $comment->comment_author_email = format_to_edit($comment->comment_author_email);
- $comment->comment_author_url = format_to_edit($comment->comment_author_url);
+ $comment->comment_author = format_to_edit( $comment->comment_author );
+ $comment->comment_author_email = format_to_edit( $comment->comment_author_email );
+ $comment->comment_author_url = format_to_edit( $comment->comment_author_url );
return $comment;
}
-function get_category_to_edit($id) {
- $category = get_category($id);
+function get_category_to_edit( $id ) {
+ $category = get_category( $id );
return $category;
}
@@ -369,7 +369,7 @@ function get_category_to_edit($id) {
function wp_dropdown_roles( $default = false ) {
global $wp_roles;
$r = '';
- foreach($wp_roles->role_names as $role => $name)
+ foreach( $wp_roles->role_names as $role => $name )
if ( $default == $role ) // Make default first in list
$p = "\n\t<option selected='selected' value='$role'>$name</option>";
else
@@ -378,19 +378,19 @@ function wp_dropdown_roles( $default = false ) {
}
-function get_user_to_edit($user_id) {
- $user = new WP_User($user_id);
- $user->user_login = wp_specialchars($user->user_login, 1);
- $user->user_email = wp_specialchars($user->user_email, 1);
- $user->user_url = wp_specialchars($user->user_url, 1);
- $user->first_name = wp_specialchars($user->first_name, 1);
- $user->last_name = wp_specialchars($user->last_name, 1);
- $user->display_name = wp_specialchars($user->display_name, 1);
- $user->nickname = wp_specialchars($user->nickname, 1);
- $user->aim = wp_specialchars($user->aim, 1);
- $user->yim = wp_specialchars($user->yim, 1);
- $user->jabber = wp_specialchars($user->jabber, 1);
- $user->description = wp_specialchars($user->description);
+function get_user_to_edit( $user_id ) {
+ $user = new WP_User( $user_id );
+ $user->user_login = wp_specialchars( $user->user_login, 1 );
+ $user->user_email = wp_specialchars( $user->user_email, 1 );
+ $user->user_url = wp_specialchars( $user->user_url, 1 );
+ $user->first_name = wp_specialchars( $user->first_name, 1 );
+ $user->last_name = wp_specialchars( $user->last_name, 1 );
+ $user->display_name = wp_specialchars( $user->display_name, 1 );
+ $user->nickname = wp_specialchars( $user->nickname, 1 );
+ $user->aim = wp_specialchars( $user->aim, 1 );
+ $user->yim = wp_specialchars( $user->yim, 1 );
+ $user->jabber = wp_specialchars( $user->jabber, 1 );
+ $user->description = wp_specialchars( $user->description );
return $user;
}
@@ -400,147 +400,147 @@ function get_user_to_edit($user_id) {
function add_user() {
if ( func_num_args() ) { // The hackiest hack that ever did hack
global $current_user, $wp_roles;
- $user_id = func_get_arg(0);
+ $user_id = func_get_arg( 0 );
- if (isset ($_POST['role'])) {
- if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) {
- $user = new WP_User($user_id);
- $user->set_role($_POST['role']);
+ if ( isset( $_POST['role'] ) ) {
+ if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ) ) {
+ $user = new WP_User( $user_id );
+ $user->set_role( $_POST['role'] );
}
}
} else {
- add_action('user_register', 'add_user'); // See above
+ add_action( 'user_register', 'add_user' ); // See above
return edit_user();
}
}
-function edit_user($user_id = 0) {
+function edit_user( $user_id = 0 ) {
global $current_user, $wp_roles, $wpdb;
- if ($user_id != 0) {
+ if ( $user_id != 0 ) {
$update = true;
$user->ID = $user_id;
- $userdata = get_userdata($user_id);
- $user->user_login = $wpdb->escape($userdata->user_login);
+ $userdata = get_userdata( $user_id );
+ $user->user_login = $wpdb->escape( $userdata->user_login );
} else {
$update = false;
$user = '';
}
- if (isset ($_POST['user_login']))
- $user->user_login = wp_specialchars(trim($_POST['user_login']));
+ if ( isset( $_POST['user_login'] ))
+ $user->user_login = wp_specialchars( trim( $_POST['user_login'] ));
$pass1 = $pass2 = '';
- if (isset ($_POST['pass1']))
+ if ( isset( $_POST['pass1'] ))
$pass1 = $_POST['pass1'];
- if (isset ($_POST['pass2']))
+ if ( isset( $_POST['pass2'] ))
$pass2 = $_POST['pass2'];
- if (isset ($_POST['role']) && current_user_can('edit_users')) {
- if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))
+ if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) {
+ if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ))
$user->role = $_POST['role'];
}
- if (isset ($_POST['email']))
- $user->user_email = wp_specialchars(trim($_POST['email']));
- if (isset ($_POST['url'])) {
- $user->user_url = wp_specialchars(trim($_POST['url']));
- $user->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
- }
- if (isset ($_POST['first_name']))
- $user->first_name = wp_specialchars(trim($_POST['first_name']));
- if (isset ($_POST['last_name']))
- $user->last_name = wp_specialchars(trim($_POST['last_name']));
- if (isset ($_POST['nickname']))
- $user->nickname = wp_specialchars(trim($_POST['nickname']));
- if (isset ($_POST['display_name']))
- $user->display_name = wp_specialchars(trim($_POST['display_name']));
- if (isset ($_POST['description']))
- $user->description = trim($_POST['description']);
- if (isset ($_POST['jabber']))
- $user->jabber = wp_specialchars(trim($_POST['jabber']));
- if (isset ($_POST['aim']))
- $user->aim = wp_specialchars(trim($_POST['aim']));
- if (isset ($_POST['yim']))
- $user->yim = wp_specialchars(trim($_POST['yim']));
+ if ( isset( $_POST['email'] ))
+ $user->user_email = wp_specialchars( trim( $_POST['email'] ));
+ if ( isset( $_POST['url'] ) ) {
+ $user->user_url = wp_specialchars( trim( $_POST['url'] ));
+ $user->user_url = preg_match( '/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url ) ? $user->user_url : 'http://'.$user->user_url;
+ }
+ if ( isset( $_POST['first_name'] ))
+ $user->first_name = wp_specialchars( trim( $_POST['first_name'] ));
+ if ( isset( $_POST['last_name'] ))
+ $user->last_name = wp_specialchars( trim( $_POST['last_name'] ));
+ if ( isset( $_POST['nickname'] ))
+ $user->nickname = wp_specialchars( trim( $_POST['nickname'] ));
+ if ( isset( $_POST['display_name'] ))
+ $user->display_name = wp_specialchars( trim( $_POST['display_name'] ));
+ if ( isset( $_POST['description'] ))
+ $user->description = trim( $_POST['description'] );
+ if ( isset( $_POST['jabber'] ))
+ $user->jabber = wp_specialchars( trim( $_POST['jabber'] ));
+ if ( isset( $_POST['aim'] ))
+ $user->aim = wp_specialchars( trim( $_POST['aim'] ));
+ if ( isset( $_POST['yim'] ))
+ $user->yim = wp_specialchars( trim( $_POST['yim'] ));
$errors = new WP_Error();
/* checking that username has been typed */
- if ($user->user_login == '')
- $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.'));
+ if ( $user->user_login == '' )
+ $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ));
/* checking the password has been typed twice */
- do_action_ref_array('check_passwords', array ($user->user_login, & $pass1, & $pass2));
+ do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 ));
- if (!$update) {
- if ($pass1 == '' || $pass2 == '')
- $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password twice.'));
+ if (!$update ) {
+ if ( $pass1 == '' || $pass2 == '' )
+ $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ));
} else {
- if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1)))
- $errors->add('pass', __("<strong>ERROR</strong>: you typed your new password only once."));
+ if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) )
+ $errors->add( 'pass', __( "<strong>ERROR</strong>: you typed your new password only once." ));
}
/* Check for "\" in password */
if( strpos( " ".$pass1, "\\" ) )
- $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'));
+ $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ));
/* checking the password has been typed twice the same */
- if ($pass1 != $pass2)
- $errors->add('pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
+ if ( $pass1 != $pass2 )
+ $errors->add( 'pass', __( '<strong>ERROR</strong>: Please type the same password in the two password fields.' ));
- if (!empty ($pass1))
+ if (!empty ( $pass1 ))
$user->user_pass = $pass1;
- if ( !validate_username($user->user_login) )
- $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));
+ if ( !validate_username( $user->user_login ) )
+ $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' ));
- if (!$update && username_exists($user->user_login))
- $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
+ if (!$update && username_exists( $user->user_login ))
+ $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' ));
/* checking e-mail address */
- if (empty ($user->user_email)) {
- $errors->add('user_email', __("<strong>ERROR</strong>: please type an e-mail address"));
+ if ( empty ( $user->user_email ) ) {
+ $errors->add( 'user_email', __( "<strong>ERROR</strong>: please type an e-mail address" ));
} else
- if (!is_email($user->user_email)) {
- $errors->add('user_email', __("<strong>ERROR</strong>: the email address isn't correct"));
+ if (!is_email( $user->user_email ) ) {
+ $errors->add( 'user_email', __( "<strong>ERROR</strong>: the email address isn't correct" ));
}
if ( $errors->get_error_codes() )
return $errors;
- if ($update) {
- $user_id = wp_update_user(get_object_vars($user));
+ if ( $update ) {
+ $user_id = wp_update_user( get_object_vars( $user ));
} else {
- $user_id = wp_insert_user(get_object_vars($user));
- wp_new_user_notification($user_id);
+ $user_id = wp_insert_user( get_object_vars( $user ));
+ wp_new_user_notification( $user_id );
}
return $user_id;
}
-function get_link_to_edit($link_id) {
- $link = get_link($link_id);
+function get_link_to_edit( $link_id ) {
+ $link = get_link( $link_id );
- $link->link_url = wp_specialchars($link->link_url, 1);
- $link->link_name = wp_specialchars($link->link_name, 1);
- $link->link_image = wp_specialchars($link->link_image, 1);
- $link->link_description = wp_specialchars($link->link_description, 1);
- $link->link_notes = wp_specialchars($link->link_notes);
- $link->link_rss = wp_specialchars($link->link_rss, 1);
- $link->link_rel = wp_specialchars($link->link_rel, 1);
+ $link->link_url = wp_specialchars( $link->link_url, 1 );
+ $link->link_name = wp_specialchars( $link->link_name, 1 );
+ $link->link_image = wp_specialchars( $link->link_image, 1 );
+ $link->link_description = wp_specialchars( $link->link_description, 1 );
+ $link->link_notes = wp_specialchars( $link->link_notes );
+ $link->link_rss = wp_specialchars( $link->link_rss, 1 );
+ $link->link_rel = wp_specialchars( $link->link_rel, 1 );
$link->post_category = $link->link_category;
return $link;
}
function get_default_link_to_edit() {
- if ( isset($_GET['linkurl']) )
- $link->link_url = wp_specialchars($_GET['linkurl'], 1);
+ if ( isset( $_GET['linkurl'] ) )
+ $link->link_url = wp_specialchars( $_GET['linkurl'], 1 );
else
$link->link_url = '';
- if ( isset($_GET['name']) )
- $link->link_name = wp_specialchars($_GET['name'], 1);
+ if ( isset( $_GET['name'] ) )
+ $link->link_name = wp_specialchars( $_GET['name'], 1 );
else
$link->link_name = '';
@@ -553,76 +553,76 @@ function add_link() {
return edit_link();
}
-function edit_link($link_id = '') {
- if (!current_user_can('manage_links'))
- wp_die(__("Cheatin' uh ?"));
+function edit_link( $link_id = '' ) {
+ if (!current_user_can( 'manage_links' ))
+ wp_die( __("Cheatin' uh ?" ));
- $_POST['link_url'] = wp_specialchars($_POST['link_url']);
- $_POST['link_url'] = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url']) ? $_POST['link_url'] : 'http://' . $_POST['link_url'];
- $_POST['link_name'] = wp_specialchars($_POST['link_name']);
- $_POST['link_image'] = wp_specialchars($_POST['link_image']);
- $_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
+ $_POST['link_url'] = wp_specialchars( $_POST['link_url'] );
+ $_POST['link_url'] = preg_match( '/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url'] ) ? $_POST['link_url'] : 'http://' . $_POST['link_url'];
+ $_POST['link_name'] = wp_specialchars( $_POST['link_name'] );
+ $_POST['link_image'] = wp_specialchars( $_POST['link_image'] );
+ $_POST['link_rss'] = wp_specialchars( $_POST['link_rss'] );
$_POST['link_category'] = $_POST['post_category'];
- if ( !empty($link_id) ) {
+ if ( !empty( $link_id ) ) {
$_POST['link_id'] = $link_id;
- return wp_update_link($_POST);
+ return wp_update_link( $_POST);
} else {
- return wp_insert_link($_POST);
+ return wp_insert_link( $_POST);
}
}
-function url_shorten($url) {
- $short_url = str_replace('http://', '', stripslashes($url));
- $short_url = str_replace('www.', '', $short_url);
- if ('/' == substr($short_url, -1))
- $short_url = substr($short_url, 0, -1);
- if (strlen($short_url) > 35)
- $short_url = substr($short_url, 0, 32).'...';
+function url_shorten( $url ) {
+ $short_url = str_replace( 'http://', '', stripslashes( $url ));
+ $short_url = str_replace( 'www.', '', $short_url );
+ if ('/' == substr( $short_url, -1 ))
+ $short_url = substr( $short_url, 0, -1 );
+ if ( strlen( $short_url ) > 35 )
+ $short_url = substr( $short_url, 0, 32 ).'...';
return $short_url;
}
-function selected($selected, $current) {
- if ($selected == $current)
+function selected( $selected, $current) {
+ if ( $selected == $current)
echo ' selected="selected"';
}
-function checked($checked, $current) {
- if ($checked == $current)
+function checked( $checked, $current) {
+ if ( $checked == $current)
echo ' checked="checked"';
}
-function return_categories_list($parent = 0) {
+function return_categories_list( $parent = 0 ) {
global $wpdb;
- return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC");
+ return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC" );
}
-function sort_cats($cat1, $cat2) {
- return strcasecmp($cat1['cat_name'], $cat2['cat_name']);
+function sort_cats( $cat1, $cat2 ) {
+ return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] );
}
-function get_nested_categories($default = 0, $parent = 0) {
+function get_nested_categories( $default = 0, $parent = 0 ) {
global $post_ID, $link_id, $mode, $wpdb;
- if ($post_ID) {
- $checked_categories = $wpdb->get_col("
+ if ( $post_ID ) {
+ $checked_categories = $wpdb->get_col( "
SELECT category_id
FROM $wpdb->categories, $wpdb->post2cat
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
- ");
+ " );
- if (count($checked_categories) == 0) {
+ if ( count( $checked_categories ) == 0 ) {
// No selected categories, strange
$checked_categories[] = $default;
}
- } else if ($link_id) {
- $checked_categories = $wpdb->get_col("
+ } else if ( $link_id ) {
+ $checked_categories = $wpdb->get_col( "
SELECT category_id
FROM $wpdb->categories, $wpdb->link2cat
WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
- ");
+ " );
- if (count($checked_categories) == 0) {
+ if ( count( $checked_categories ) == 0 ) {
// No selected categories, strange
$checked_categories[] = $default;
}
@@ -630,59 +630,59 @@ function get_nested_categories($default = 0, $parent = 0) {
$checked_categories[] = $default;
}
- $cats = return_categories_list($parent);
+ $cats = return_categories_list( $parent);
$result = array ();
- if (is_array($cats)) {
- foreach ($cats as $cat) {
+ if ( is_array( $cats ) ) {
+ foreach ( $cats as $cat) {
if ( $cat == 0 ) { // HACK, added 2006-05-13
$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
continue;
}
- $result[$cat]['children'] = get_nested_categories($default, $cat);
+ $result[$cat]['children'] = get_nested_categories( $default, $cat);
$result[$cat]['cat_ID'] = $cat;
- $result[$cat]['checked'] = in_array($cat, $checked_categories);
- $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
+ $result[$cat]['checked'] = in_array( $cat, $checked_categories );
+ $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);
}
}
- usort($result, 'sort_cats');
+ usort( $result, 'sort_cats' );
return $result;
}
-function write_nested_categories($categories) {
- foreach ($categories as $category) {
- echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n";
+function write_nested_categories( $categories ) {
+ foreach ( $categories as $category ) {
+ echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( $category['cat_name'] ), "</label></li>";
if ( $category['children'] ) {
echo "<ul>\n";
- write_nested_categories($category['children']);
+ write_nested_categories( $category['children'] );
echo "</ul>\n";
}
}
}
-function dropdown_categories($default = 0) {
- write_nested_categories(get_nested_categories($default));
+function dropdown_categories( $default = 0 ) {
+ write_nested_categories( get_nested_categories( $default) );
}
-function return_link_categories_list($parent = 0) {
+function return_link_categories_list( $parent = 0 ) {
global $wpdb;
- return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC");
+ return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC" );
}
function get_nested_link_categories( $default = 0, $parent = 0 ) {
global $post_ID, $link_id, $mode, $wpdb;
- if ($link_id) {
- $checked_categories = $wpdb->get_col("
+ if ( $link_id ) {
+ $checked_categories = $wpdb->get_col( "
SELECT category_id
FROM $wpdb->categories, $wpdb->link2cat
WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
- ");
+ " );
- if (count($checked_categories) == 0) {
+ if ( count( $checked_categories ) == 0 ) {
// No selected categories, strange
$checked_categories[] = $default;
}
@@ -690,43 +690,43 @@ function get_nested_link_categories( $default = 0, $parent = 0 ) {
$checked_categories[] = $default;
}
- $cats = return_link_categories_list($parent);
+ $cats = return_link_categories_list( $parent);
$result = array ();
- if (is_array($cats)) {
- foreach ($cats as $cat) {
- $result[$cat]['children'] = get_nested_link_categories($default, $cat);
+ if ( is_array( $cats ) ) {
+ foreach ( $cats as $cat) {
+ $result[$cat]['children'] = get_nested_link_categories( $default, $cat);
$result[$cat]['cat_ID'] = $cat;
- $result[$cat]['checked'] = in_array($cat, $checked_categories);
- $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
+ $result[$cat]['checked'] = in_array( $cat, $checked_categories );
+ $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);
}
}
- usort($result, 'sort_cats');
+ usort( $result, 'sort_cats' );
return $result;
}
-function dropdown_link_categories($default = 0) {
- write_nested_categories(get_nested_link_categories($default));
+function dropdown_link_categories( $default = 0 ) {
+ write_nested_categories( get_nested_link_categories( $default) );
}
// Dandy new recursive multiple category stuff.
-function cat_rows($parent = 0, $level = 0, $categories = 0) {
+function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
global $wpdb, $class;
- if (!$categories)
- $categories = get_categories('hide_empty=0');
+ if (!$categories )
+ $categories = get_categories( 'hide_empty=0' );
- if ($categories) {
- foreach ($categories as $category) {
+ if ( $categories ) {
+ foreach ( $categories as $category ) {
if ( $category->cat_ID == 0 ) { // HACK, added 2006-05-13
$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
continue;
}
- if ($category->category_parent == $parent) {
+ if ( $category->category_parent == $parent) {
echo "\t" . _cat_row( $category, $level );
- cat_rows($category->cat_ID, $level +1, $categories);
+ cat_rows( $category->cat_ID, $level +1, $categories );
}
}
} else {
@@ -737,20 +737,20 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
function _cat_row( $category, $level, $name_override = false ) {
global $class;
- $pad = str_repeat('&#8212; ', $level);
- if ( current_user_can('manage_categories') ) {
- $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
- $default_cat_id = get_option('default_category');
- $default_link_cat_id = get_option('default_link_category');
+ $pad = str_repeat( '&#8212; ', $level );
+ if ( current_user_can( 'manage_categories' ) ) {
+ $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__( 'Edit' )."</a></td>";
+ $default_cat_id = get_option( 'default_category' );
+ $default_link_cat_id = get_option( 'default_link_category' );
- if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
- $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";
+ if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) )
+ $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf( __("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop." ), js_escape( $category->cat_name ), js_escape( get_catname( $default_cat_id )), js_escape( get_catname( $default_link_cat_id ) ) ) . "' );\" class='delete'>".__( 'Delete' )."</a>";
else
- $edit .= "<td style='text-align:center'>".__("Default");
+ $edit .= "<td style='text-align:center'>".__( "Default" );
} else
$edit = '';
- $class = ( ( defined('DOING_AJAX') && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
+ $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
$category->category_count = number_format( $category->category_count );
$category->link_count = number_format( $category->link_count );
@@ -763,91 +763,90 @@ function _cat_row( $category, $level, $name_override = false ) {
<td>$edit</td>\n\t</tr>\n";
}
-function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
+function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
global $wpdb, $class, $post;
- if (!$pages)
- $pages = get_pages('sort_column=menu_order');
+ if (!$pages )
+ $pages = get_pages( 'sort_column=menu_order' );
- if (! $pages)
+ if (! $pages )
return false;
- foreach ($pages as $post) {
- setup_postdata($post);
+ foreach ( $pages as $post) {
+ setup_postdata( $post);
if ( $hierarchy && ($post->post_parent != $parent) )
continue;
- $post->post_title = wp_specialchars($post->post_title);
- $pad = str_repeat('&#8212; ', $level);
+ $post->post_title = wp_specialchars( $post->post_title );
+ $pad = str_repeat( '&#8212; ', $level );
$id = $post->ID;
- $class = ('alternate' == $class) ? '' : 'alternate';
+ $class = ('alternate' == $class ) ? '' : 'alternate';
?>
<tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
<th scope="row" style="text-align: center"><?php echo $post->ID; ?></th>
<td>
<?php echo $pad; ?><?php the_title() ?>
- <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?>
</td>
<td><?php the_author() ?></td>
- <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
- <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
- <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
- <td><?php if ( current_user_can('delete_page', $id) ) { echo "<a href='" . wp_nonce_url("page.php?action=delete&amp;post=$id", 'delete-page_' . $id) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+ <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else echo mysql2date( 'Y-m-d g:i a', $post->post_modified ); ?></td>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e( 'View' ); ?></a></td>
+ <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td>
+ <td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&amp;post=$id", 'delete-page_' . $id ) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf( __("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop." ), js_escape( get_the_title() ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td>
</tr>
<?php
- if ( $hierarchy) page_rows($id, $level + 1, $pages);
+ if ( $hierarchy ) page_rows( $id, $level + 1, $pages );
}
}
function user_row( $user_object, $style = '' ) {
global $current_user;
- if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) )
+ if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
$user_object = new WP_User( (int) $user_object );
$email = $user_object->user_email;
$url = $user_object->user_url;
- $short_url = str_replace('http://', '', $url);
- $short_url = str_replace('www.', '', $short_url);
- if ('/' == substr($short_url, -1))
- $short_url = substr($short_url, 0, -1);
- if (strlen($short_url) > 35)
- $short_url = substr($short_url, 0, 32).'...';
- $numposts = get_usernumposts($user_object->ID);
+ $short_url = str_replace( 'http://', '', $url );
+ $short_url = str_replace( 'www.', '', $short_url );
+ if ('/' == substr( $short_url, -1 ))
+ $short_url = substr( $short_url, 0, -1 );
+ if ( strlen( $short_url ) > 35 )
+ $short_url = substr( $short_url, 0, 32 ).'...';
+ $numposts = get_usernumposts( $user_object->ID );
$r = "<tr id='user-$user_object->ID'$style>
<td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
<td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
<td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
- <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
+ <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>
<td><a href='$url' title='website: $url'>$short_url</a></td>";
$r .= "\n\t\t<td align='center'>";
- if ($numposts > 0) {
- $r .= "<a href='edit.php?author=$user_object->ID' title='" . __('View posts by this author') . "' class='edit'>";
- $r .= sprintf(__('View %1$s %2$s'), $numposts, __ngettext('post', 'posts', $numposts));
+ if ( $numposts > 0 ) {
+ $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
+ $r .= sprintf( __('View %1$s %2$s' ), $numposts, __ngettext( 'post', 'posts', $numposts ));
}
$r .= "</td>\n\t\t<td>";
- $edit_link = add_query_arg('wp_http_referer', wp_specialchars(urlencode(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id=$user_object->ID");
+ $edit_link = add_query_arg( 'wp_http_referer', wp_specialchars( urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" );
if ( ( is_site_admin() || $current_user->ID == $user_object->ID ) && current_user_can('edit_user', $user_object->ID) )
- $r .= "<a href='$edit_link' class='edit'>".__('Edit')."</a>";
+ $r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>";
$r .= "</td>\n\t</tr>";
return $r;
}
-function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
+function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
global $wpdb;
- if (!$categories)
- $categories = get_categories('hide_empty=0');
-
- if ($categories) {
- foreach ($categories as $category) {
- if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
- $pad = str_repeat('&#8211; ', $level);
- $category->cat_name = wp_specialchars($category->cat_name);
+ if (!$categories )
+ $categories = get_categories( 'hide_empty=0' );
+
+ if ( $categories ) {
+ foreach ( $categories as $category ) {
+ if ( $currentcat != $category->cat_ID && $parent == $category->category_parent) {
+ $pad = str_repeat( '&#8211; ', $level );
+ $category->cat_name = wp_specialchars( $category->cat_name );
echo "\n\t<option value='$category->cat_ID'";
- if ($currentparent == $category->cat_ID)
+ if ( $currentparent == $category->cat_ID )
echo " selected='selected'";
echo ">$pad$category->cat_name</option>";
- wp_dropdown_cats($currentcat, $currentparent, $category->cat_ID, $level +1, $categories);
+ wp_dropdown_cats( $currentcat, $currentparent, $category->cat_ID, $level +1, $categories );
}
}
} else {
@@ -855,45 +854,45 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev
}
}
-function wp_create_thumbnail($file, $max_side, $effect = '') {
+function wp_create_thumbnail( $file, $max_side, $effect = '' ) {
// 1 = GIF, 2 = JPEG, 3 = PNG
- if (file_exists($file)) {
- $type = getimagesize($file);
+ if ( file_exists( $file ) ) {
+ $type = getimagesize( $file );
// if the associated function doesn't exist - then it's not
// handle. duh. i hope.
- if (!function_exists('imagegif') && $type[2] == 1) {
- $error = __('Filetype not supported. Thumbnail not created.');
+ if (!function_exists( 'imagegif' ) && $type[2] == 1 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
}
- elseif (!function_exists('imagejpeg') && $type[2] == 2) {
- $error = __('Filetype not supported. Thumbnail not created.');
+ elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
}
- elseif (!function_exists('imagepng') && $type[2] == 3) {
- $error = __('Filetype not supported. Thumbnail not created.');
+ elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
} else {
// create the initial copy from the original file
- if ($type[2] == 1) {
- $image = imagecreatefromgif($file);
+ if ( $type[2] == 1 ) {
+ $image = imagecreatefromgif( $file );
}
- elseif ($type[2] == 2) {
- $image = imagecreatefromjpeg($file);
+ elseif ( $type[2] == 2 ) {
+ $image = imagecreatefromjpeg( $file );
}
- elseif ($type[2] == 3) {
- $image = imagecreatefrompng($file);
+ elseif ( $type[2] == 3 ) {
+ $image = imagecreatefrompng( $file );
}
- if (function_exists('imageantialias'))
- imageantialias($image, TRUE);
+ if ( function_exists( 'imageantialias' ))
+ imageantialias( $image, TRUE );
- $image_attr = getimagesize($file);
+ $image_attr = getimagesize( $file );
// figure out the longest side
- if ($image_attr[0] > $image_attr[1]) {
+ if ( $image_attr[0] > $image_attr[1] ) {
$image_width = $image_attr[0];
$image_height = $image_attr[1];
$image_new_width = $max_side;
@@ -911,38 +910,38 @@ function wp_create_thumbnail($file, $max_side, $effect = '') {
//height > width
}
- $thumbnail = imagecreatetruecolor($image_new_width, $image_new_height);
- @ imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]);
+ $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
+ @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] );
// If no filters change the filename, we'll do a default transformation.
- if ( basename($file) == $thumb = apply_filters('thumbnail_filename', basename($file)) )
- $thumb = preg_replace('!(\.[^.]+)?$!', __('.thumbnail').'$1', basename($file), 1);
+ if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) )
+ $thumb = preg_replace( '!(\.[^.]+)?$!', __( '.thumbnail' ).'$1', basename( $file ), 1 );
- $thumbpath = str_replace(basename($file), $thumb, $file);
+ $thumbpath = str_replace( basename( $file ), $thumb, $file );
// move the thumbnail to it's final destination
- if ($type[2] == 1) {
- if (!imagegif($thumbnail, $thumbpath)) {
- $error = __("Thumbnail path invalid");
+ if ( $type[2] == 1 ) {
+ if (!imagegif( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
}
}
- elseif ($type[2] == 2) {
- if (!imagejpeg($thumbnail, $thumbpath)) {
- $error = __("Thumbnail path invalid");
+ elseif ( $type[2] == 2 ) {
+ if (!imagejpeg( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
}
}
- elseif ($type[2] == 3) {
- if (!imagepng($thumbnail, $thumbpath)) {
- $error = __("Thumbnail path invalid");
+ elseif ( $type[2] == 3 ) {
+ if (!imagepng( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
}
}
}
} else {
- $error = __('File not found');
+ $error = __( 'File not found' );
}
- if (!empty ($error)) {
+ if (!empty ( $error ) ) {
return $error;
} else {
apply_filters( 'wp_create_thumbnail', $thumbpath );
@@ -951,21 +950,21 @@ function wp_create_thumbnail($file, $max_side, $effect = '') {
}
// Some postmeta stuff
-function has_meta($postid) {
+function has_meta( $postid ) {
global $wpdb;
- return $wpdb->get_results("
+ return $wpdb->get_results( "
SELECT meta_key, meta_value, meta_id, post_id
FROM $wpdb->postmeta
WHERE post_id = '$postid'
- ORDER BY meta_key,meta_id", ARRAY_A);
+ ORDER BY meta_key,meta_id", ARRAY_A );
}
-function list_meta($meta) {
+function list_meta( $meta ) {
global $post_ID;
// Exit if no meta
- if (!$meta) {
+ if (!$meta ) {
echo '<tbody id="the-list"><tr style="display: none;"><td>&nbsp;</td></tr></tbody>'; //TBODY needed for list-manipulation JS
return;
}
@@ -973,26 +972,26 @@ function list_meta($meta) {
?>
<thead>
<tr>
- <th><?php _e('Key') ?></th>
- <th><?php _e('Value') ?></th>
- <th colspan='2'><?php _e('Action') ?></th>
+ <th><?php _e( 'Key' ) ?></th>
+ <th><?php _e( 'Value' ) ?></th>
+ <th colspan='2'><?php _e( 'Action' ) ?></th>
</tr>
</thead>
<?php
$r ="\n\t<tbody id='the-list'>";
- foreach ($meta as $entry) {
+ foreach ( $meta as $entry ) {
++ $count;
- if ($count % 2)
+ if ( $count % 2 )
$style = 'alternate';
else
$style = '';
- if ('_' == $entry['meta_key'] { 0 })
+ if ('_' == $entry['meta_key'] { 0 } )
$style .= ' hidden';
- if ( is_serialized($entry['meta_value']) ) {
- if ( is_serialized_string($entry['meta_value']) ) {
+ if ( is_serialized( $entry['meta_value'] ) ) {
+ if ( is_serialized_string( $entry['meta_value'] ) ) {
// this is a serialized string, so we should display it
- $entry['meta_value'] = maybe_unserialize($entry['meta_value']);
+ $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
} else {
// this is a serialized array/object so we should NOT display it
--$count;
@@ -1000,16 +999,16 @@ function list_meta($meta) {
}
}
- $key_js = js_escape($entry['meta_key']);
+ $key_js = js_escape( $entry['meta_key'] );
$entry['meta_key'] = wp_specialchars( $entry['meta_key'], true );
$entry['meta_value'] = wp_specialchars( $entry['meta_value'], true );
$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>";
- $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />";
+ $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__( 'Update' )."' /><br />";
$r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
- $r .= sprintf(__("You are about to delete the &quot;%s&quot; custom field on this post.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), $key_js);
- $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>";
+ $r .= sprintf( __("You are about to delete the &quot;%s&quot; custom field on this post.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop." ), $key_js );
+ $r .= "' );\" class='deletemeta' tabindex='6' value='".__( 'Delete' )."' /></td>";
$r .= "\n\t</tr>";
}
echo $r;
@@ -1020,45 +1019,45 @@ function list_meta($meta) {
function get_meta_keys() {
global $wpdb;
- $keys = $wpdb->get_col("
+ $keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
- ORDER BY meta_key");
+ ORDER BY meta_key" );
return $keys;
}
function meta_form() {
global $wpdb;
- $limit = (int) apply_filters('postmeta_form_limit', 30);
- $keys = $wpdb->get_col("
+ $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
+ $keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
ORDER BY meta_id DESC
- LIMIT $limit");
- natcasesort($keys);
+ LIMIT $limit" );
+ natcasesort( $keys );
?>
-<h3><?php _e('Add a new custom field:') ?></h3>
+<h3><?php _e( 'Add a new custom field:' ) ?></h3>
<table id="newmeta" cellspacing="3" cellpadding="3">
<tr>
-<th colspan="2"><?php _e('Key') ?></th>
-<th><?php _e('Value') ?></th>
+<th colspan="2"><?php _e( 'Key' ) ?></th>
+<th><?php _e( 'Value' ) ?></th>
</tr>
<tr valign="top">
<td align="right" width="18%">
<?php if ( $keys ) : ?>
<select id="metakeyselect" name="metakeyselect" tabindex="7">
-<option value="#NONE#"><?php _e('- Select -'); ?></option>
+<option value="#NONE#"><?php _e( '- Select -' ); ?></option>
<?php
foreach ( $keys as $key ) {
- $key = wp_specialchars($key, 1);
+ $key = wp_specialchars( $key, 1 );
echo "\n\t<option value='$key'>$key</option>";
}
?>
-</select> <?php _e('or'); ?>
+</select> <?php _e( 'or' ); ?>
<?php endif; ?>
</td>
<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
@@ -1066,101 +1065,101 @@ function meta_form() {
</tr>
</table>
-<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
+<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field &raquo;' ) ?>" /></p>
<?php
}
-function add_meta($post_ID) {
+function add_meta( $post_ID ) {
global $wpdb;
$post_ID = (int) $post_ID;
- $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect'])));
- $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput'])));
- $metavalue = maybe_serialize(stripslashes((trim($_POST['metavalue']))));
- $metavalue = $wpdb->escape($metavalue);
+ $metakeyselect = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) );
+ $metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) );
+ $metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) ));
+ $metavalue = $wpdb->escape( $metavalue );
- if ( ('0' === $metavalue || !empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput)) ) {
+ if ( ('0' === $metavalue || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {
// We have a key/value pair. If both the select and the
// input for the key have data, the input takes precedence:
if ('#NONE#' != $metakeyselect)
$metakey = $metakeyselect;
- if ($metakeyinput)
+ if ( $metakeyinput)
$metakey = $metakeyinput; // default
- $result = $wpdb->query("
+ $result = $wpdb->query( "
INSERT INTO $wpdb->postmeta
- (post_id,meta_key,meta_value)
- VALUES ('$post_ID','$metakey','$metavalue')
- ");
+ (post_id,meta_key,meta_value )
+ VALUES ('$post_ID','$metakey','$metavalue' )
+ " );
return $wpdb->insert_id;
}
return false;
} // add_meta
-function delete_meta($mid) {
+function delete_meta( $mid ) {
global $wpdb;
$mid = (int) $mid;
- return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
+ return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" );
}
-function update_meta($mid, $mkey, $mvalue) {
+function update_meta( $mid, $mkey, $mvalue ) {
global $wpdb;
- $mvalue = maybe_serialize(stripslashes($mvalue));
- $mvalue = $wpdb->escape($mvalue);
+ $mvalue = maybe_serialize( stripslashes( $mvalue ));
+ $mvalue = $wpdb->escape( $mvalue );
$mid = (int) $mid;
- return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
+ return $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'" );
}
-function get_post_meta_by_id($mid) {
+function get_post_meta_by_id( $mid ) {
global $wpdb;
$mid = (int) $mid;
- $meta = $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'");
- if ( is_serialized_string($meta->meta_value) )
- $meta->meta_value = maybe_unserialize($meta->meta_value);
+ $meta = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'" );
+ if ( is_serialized_string( $meta->meta_value ) )
+ $meta->meta_value = maybe_unserialize( $meta->meta_value );
return $meta;
}
-function touch_time($edit = 1, $for_post = 1) {
+function touch_time( $edit = 1, $for_post = 1 ) {
global $wp_locale, $post, $comment;
if ( $for_post )
- $edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true;
+ $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
- echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__('Edit timestamp').'</label></legend>';
+ echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
- $time_adj = time() + (get_option('gmt_offset') * 3600);
+ $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
- $jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj);
- $mm = ($edit) ? mysql2date('m', $post_date) : gmdate('m', $time_adj);
- $aa = ($edit) ? mysql2date('Y', $post_date) : gmdate('Y', $time_adj);
- $hh = ($edit) ? mysql2date('H', $post_date) : gmdate('H', $time_adj);
- $mn = ($edit) ? mysql2date('i', $post_date) : gmdate('i', $time_adj);
- $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj);
+ $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
+ $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
+ $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
+ $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
+ $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
+ $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n";
- for ($i = 1; $i < 13; $i = $i +1) {
+ for ( $i = 1; $i < 13; $i = $i +1 ) {
echo "\t\t\t<option value=\"$i\"";
- if ($i == $mm)
+ if ( $i == $mm )
echo ' selected="selected"';
- echo '>' . $wp_locale->get_month($i) . "</option>\n";
+ echo '>' . $wp_locale->get_month( $i ) . "</option>\n";
}
?>
</select>
<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/>
-<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
-<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
-<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
-<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
+<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
+<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
+<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
+<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
<?php
if ( $edit ) {
- _e('Existing timestamp');
- //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn";
- echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn);
+ _e( 'Existing timestamp' );
+ //echo ': ' . $wp_locale->get_month( $mm ) . "$jj, $aa @ $hh:$mn";
+ echo sprintf( __(': %1$s %2$s, %3$s @ %4$s:%5$s' ), $wp_locale->get_month( $mm ), $jj, $aa, $hh, $mn );
}
?>
</fieldset>
@@ -1169,50 +1168,50 @@ function touch_time($edit = 1, $for_post = 1) {
}
// insert_with_markers: Owen Winkler, fixed by Eric Anderson
-// Inserts an array of strings into a file (.htaccess), placing it between
+// Inserts an array of strings into a file (.htaccess ), placing it between
// BEGIN and END markers. Replaces existing marked info. Retains surrounding
// data. Creates file if none exists.
// Returns true on write success, false on failure.
-function insert_with_markers($filename, $marker, $insertion) {
+function insert_with_markers( $filename, $marker, $insertion ) {
return true;
- if (!file_exists($filename) || is_writeable($filename)) {
- if (!file_exists($filename)) {
+ if (!file_exists( $filename ) || is_writeable( $filename ) ) {
+ if (!file_exists( $filename ) ) {
$markerdata = '';
} else {
- $markerdata = explode("\n", implode('', file($filename)));
+ $markerdata = explode( "\n", implode( '', file( $filename ) ) );
}
- $f = fopen($filename, 'w');
+ $f = fopen( $filename, 'w' );
$foundit = false;
- if ($markerdata) {
+ if ( $markerdata ) {
$state = true;
- foreach ($markerdata as $n => $markerline) {
- if (strstr($markerline, "# BEGIN {$marker}"))
+ foreach ( $markerdata as $n => $markerline ) {
+ if ( strstr( $markerline, "# BEGIN {$marker}" ))
$state = false;
- if ($state) {
- if ( $n + 1 < count($markerdata) )
- fwrite($f, "{$markerline}\n");
+ if ( $state ) {
+ if ( $n + 1 < count( $markerdata ) )
+ fwrite( $f, "{$markerline}\n" );
else
- fwrite($f, "{$markerline}");
+ fwrite( $f, "{$markerline}" );
}
- if (strstr($markerline, "# END {$marker}")) {
- fwrite($f, "# BEGIN {$marker}\n");
- if (is_array($insertion))
- foreach ($insertion as $insertline)
- fwrite($f, "{$insertline}\n");
- fwrite($f, "# END {$marker}\n");
+ if ( strstr( $markerline, "# END {$marker}" ) ) {
+ fwrite( $f, "# BEGIN {$marker}\n" );
+ if ( is_array( $insertion ))
+ foreach ( $insertion as $insertline )
+ fwrite( $f, "{$insertline}\n" );
+ fwrite( $f, "# END {$marker}\n" );
$state = true;
$foundit = true;
}
}
}
if (!$foundit) {
- fwrite($f, "# BEGIN {$marker}\n");
- foreach ($insertion as $insertline)
- fwrite($f, "{$insertline}\n");
- fwrite($f, "# END {$marker}\n");
+ fwrite( $f, "# BEGIN {$marker}\n" );
+ foreach ( $insertion as $insertline )
+ fwrite( $f, "{$insertline}\n" );
+ fwrite( $f, "# END {$marker}\n" );
}
- fclose($f);
+ fclose( $f );
return true;
} else {
return false;
@@ -1220,24 +1219,24 @@ function insert_with_markers($filename, $marker, $insertion) {
}
// extract_from_markers: Owen Winkler
-// Returns an array of strings from a file (.htaccess) from between BEGIN
+// Returns an array of strings from a file (.htaccess ) from between BEGIN
// and END markers.
-function extract_from_markers($filename, $marker) {
+function extract_from_markers( $filename, $marker ) {
$result = array ();
- if (!file_exists($filename)) {
+ if (!file_exists( $filename ) ) {
return $result;
}
- if ($markerdata = explode("\n", implode('', file($filename))));
+ if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));
{
$state = false;
- foreach ($markerdata as $markerline) {
- if (strstr($markerline, "# END {$marker}"))
+ foreach ( $markerdata as $markerline ) {
+ if ( strstr( $markerline, "# END {$marker}" ))
$state = false;
- if ($state)
+ if ( $state )
$result[] = $markerline;
- if (strstr($markerline, "# BEGIN {$marker}"))
+ if ( strstr( $markerline, "# BEGIN {$marker}" ))
$state = true;
}
}
@@ -1252,8 +1251,8 @@ function got_mod_rewrite() {
if ( !$is_apache )
return false;
- if ( function_exists('apache_get_modules') ) {
- if ( !in_array('mod_rewrite', apache_get_modules()) )
+ if ( function_exists( 'apache_get_modules' ) ) {
+ if ( !in_array( 'mod_rewrite', apache_get_modules() ) )
return false;
}
@@ -1264,17 +1263,17 @@ function save_mod_rewrite_rules() {
global $is_apache, $wp_rewrite;
$home_path = get_home_path();
- if (!$wp_rewrite->using_mod_rewrite_permalinks())
+ if (!$wp_rewrite->using_mod_rewrite_permalinks() )
return;
- if (!((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')))
+ if (!((!file_exists( $home_path.'.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path.'.htaccess' ) ) )
return;
- if (! got_mod_rewrite())
+ if (! got_mod_rewrite() )
return;
- $rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
- insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
+ $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
+ insert_with_markers( $home_path.'.htaccess', 'WordPress', $rules );
}
function get_broken_themes() {
@@ -1290,17 +1289,17 @@ function get_page_templates() {
$templates = $themes[$theme]['Template Files'];
$page_templates = array ();
- if (is_array($templates)) {
- foreach ($templates as $template) {
- $template_data = implode('', file(ABSPATH.$template));
- preg_match("|Template Name:(.*)|i", $template_data, $name);
- preg_match("|Description:(.*)|i", $template_data, $description);
+ if ( is_array( $templates ) ) {
+ foreach ( $templates as $template ) {
+ $template_data = implode( '', file( ABSPATH.$template ));
+ preg_match( "|Template Name:(.* )|i", $template_data, $name );
+ preg_match( "|Description:(.* )|i", $template_data, $description );
$name = $name[1];
$description = $description[1];
- if (!empty ($name)) {
- $page_templates[trim($name)] = basename($template);
+ if (!empty ( $name ) ) {
+ $page_templates[trim( $name )] = basename( $template );
}
}
}
@@ -1308,10 +1307,10 @@ function get_page_templates() {
return $page_templates;
}
-function page_template_dropdown($default = '') {
+function page_template_dropdown( $default = '' ) {
$templates = get_page_templates();
- foreach (array_keys($templates) as $template)
- : if ($default == $templates[$template])
+ foreach (array_keys( $templates ) as $template )
+ : if ( $default == $templates[$template] )
$selected = " selected='selected'";
else
$selected = '';
@@ -1319,26 +1318,26 @@ function page_template_dropdown($default = '') {
endforeach;
}
-function parent_dropdown($default = 0, $parent = 0, $level = 0) {
+function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
global $wpdb, $post_ID;
- $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");
+ $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" );
- if ($items) {
- foreach ($items as $item) {
+ if ( $items ) {
+ foreach ( $items as $item ) {
// A page cannot be it's own parent.
- if (!empty ($post_ID)) {
- if ($item->ID == $post_ID) {
+ if (!empty ( $post_ID ) ) {
+ if ( $item->ID == $post_ID ) {
continue;
}
}
- $pad = str_repeat('&nbsp;', $level * 3);
- if ($item->ID == $default)
+ $pad = str_repeat( '&nbsp;', $level * 3 );
+ if ( $item->ID == $default)
$current = ' selected="selected"';
else
$current = '';
echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>";
- parent_dropdown($default, $item->ID, $level +1);
+ parent_dropdown( $default, $item->ID, $level +1 );
}
} else {
return false;
@@ -1354,37 +1353,38 @@ function user_can_access_admin_page() {
global $plugin_page;
$parent = get_admin_page_parent();
- /*echo "pa: $parent pn: $pagenow pp: $plugin_page<br/>";
- echo "<pre>";
- print_r($_wp_menu_nopriv);
- print_r($_wp_submenu_nopriv);
- echo "</pre>";*/
- if ( isset($_wp_submenu_nopriv[$parent][$pagenow]) )
+
+ if ( isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
return false;
- if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$plugin_page]) )
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
return false;
- if ( empty($parent) ) {
- if ( isset($_wp_menu_nopriv[$pagenow]) )
+ if ( empty( $parent) ) {
+ if ( isset( $_wp_menu_nopriv[$pagenow] ) )
return false;
- if ( isset($_wp_submenu_nopriv[$pagenow][$pagenow]) )
+ if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
return false;
- if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) )
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
return false;
- foreach (array_keys($_wp_submenu_nopriv) as $key) {
- if ( isset($_wp_submenu_nopriv[$key][$pagenow]) )
+ foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
+ if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
return false;
- if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page]) )
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
return false;
}
return true;
}
- if (isset ($submenu[$parent])) {
- foreach ($submenu[$parent] as $submenu_array) {
- if ($submenu_array[2] == $pagenow) {
- if (current_user_can($submenu_array[1]))
+ if ( isset( $submenu[$parent] ) ) {
+ foreach ( $submenu[$parent] as $submenu_array ) {
+ if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
+ if ( current_user_can( $submenu_array[1] ))
+ return true;
+ else
+ return false;
+ } else if ( $submenu_array[2] == $pagenow ) {
+ if ( current_user_can( $submenu_array[1] ))
return true;
else
return false;
@@ -1392,15 +1392,15 @@ function user_can_access_admin_page() {
}
}
- foreach ($menu as $menu_array) {
- if ($menu_array[2] == $parent) {
- if (current_user_can($menu_array[1]))
+ foreach ( $menu as $menu_array ) {
+ if ( $menu_array[2] == $parent) {
+ if ( current_user_can( $menu_array[1] ))
return true;
else
return false;
}
}
-
+
return true;
}
@@ -1411,44 +1411,55 @@ function get_admin_page_title() {
global $pagenow;
global $plugin_page;
- if (isset ($title) && !empty ($title)) {
+ if ( isset( $title ) && !empty ( $title ) ) {
return $title;
}
- $hook = get_plugin_page_hook($plugin_page, $pagenow);
+ $hook = get_plugin_page_hook( $plugin_page, $pagenow );
$parent = $parent1 = get_admin_page_parent();
- if (empty ($parent)) {
- foreach ($menu as $menu_array) {
- if (isset ($menu_array[3])) {
- if ($menu_array[2] == $pagenow) {
+ if ( empty ( $parent) ) {
+ foreach ( $menu as $menu_array ) {
+ if ( isset( $menu_array[3] ) ) {
+ if ( $menu_array[2] == $pagenow ) {
$title = $menu_array[3];
return $menu_array[3];
} else
- if (isset ($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) {
+ if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
$title = $menu_array[3];
return $menu_array[3];
}
+ } else {
+ $title = $menu_array[0];
+ return $title;
}
}
} else {
- foreach (array_keys($submenu) as $parent) {
- foreach ($submenu[$parent] as $submenu_array) {
- if (isset ($submenu_array[3])) {
- if ($submenu_array[2] == $pagenow) {
+ foreach (array_keys( $submenu ) as $parent) {
+ foreach ( $submenu[$parent] as $submenu_array ) {
+ if ( isset( $plugin_page ) &&
+ ($plugin_page == $submenu_array[2] ) &&
+ (($parent == $pagenow ) || ($parent == $plugin_page ) || ($plugin_page == $hook ) || (($pagenow == 'admin.php' ) && ($parent1 != $submenu_array[2] ) ) )
+ ) {
$title = $submenu_array[3];
return $submenu_array[3];
- } else
- if (isset ($plugin_page) && ($plugin_page == $submenu_array[2]) && (($parent == $pagenow) || ($parent == $plugin_page) || ($plugin_page == $hook) || (($pagenow == 'admin.php') && ($parent1 != $submenu_array[2])))) {
- $title = $submenu_array[3];
- return $submenu_array[3];
- }
+ }
+
+ if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page
+ continue;
+
+ if ( isset( $submenu_array[3] ) ) {
+ $title = $submenu_array[3];
+ return $submenu_array[3];
+ } else {
+ $title = $submenu_array[0];
+ return $title;
}
}
}
}
- return '';
+ return $title;
}
function get_admin_page_parent() {
@@ -1461,46 +1472,46 @@ function get_admin_page_parent() {
global $_wp_menu_nopriv;
global $_wp_submenu_nopriv;
- if ( !empty ($parent_file) ) {
- if ( isset($_wp_real_parent_file[$parent_file]) )
+ if ( !empty ( $parent_file ) ) {
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
- if ($pagenow == 'admin.php' && isset ($plugin_page)) {
- foreach ($menu as $parent_menu) {
- if ($parent_menu[2] == $plugin_page) {
+ if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
+ foreach ( $menu as $parent_menu ) {
+ if ( $parent_menu[2] == $plugin_page ) {
$parent_file = $plugin_page;
- if ( isset($_wp_real_parent_file[$parent_file]) )
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
}
- if ( isset($_wp_menu_nopriv[$plugin_page]) ) {
+ if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) {
$parent_file = $plugin_page;
- if ( isset($_wp_real_parent_file[$parent_file]) )
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
}
- if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) ) {
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
$parent_file = $pagenow;
- if ( isset($_wp_real_parent_file[$parent_file]) )
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
- foreach (array_keys($submenu) as $parent) {
- foreach ($submenu[$parent] as $submenu_array) {
- if ( isset($_wp_real_parent_file[$parent]) )
+ foreach (array_keys( $submenu ) as $parent) {
+ foreach ( $submenu[$parent] as $submenu_array ) {
+ if ( isset( $_wp_real_parent_file[$parent] ) )
$parent = $_wp_real_parent_file[$parent];
- if ($submenu_array[2] == $pagenow) {
+ if ( $submenu_array[2] == $pagenow ) {
$parent_file = $parent;
return $parent;
} else
- if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) {
+ if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
$parent_file = $parent;
return $parent;
}
@@ -1511,36 +1522,36 @@ function get_admin_page_parent() {
return '';
}
-function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') {
+function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
global $menu, $admin_page_hooks;
- $file = plugin_basename($file);
+ $file = plugin_basename( $file );
- $menu[] = array ($menu_title, $access_level, $file, $page_title);
+ $menu[] = array ( $menu_title, $access_level, $file, $page_title );
- $admin_page_hooks[$file] = sanitize_title($menu_title);
+ $admin_page_hooks[$file] = sanitize_title( $menu_title );
- $hookname = get_plugin_page_hookname($file, '');
- if (!empty ($function) && !empty ($hookname))
- add_action($hookname, $function);
+ $hookname = get_plugin_page_hookname( $file, '' );
+ if (!empty ( $function ) && !empty ( $hookname ))
+ add_action( $hookname, $function );
return $hookname;
}
-function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file, $function = '') {
+function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) {
global $submenu;
global $menu;
global $_wp_real_parent_file;
global $_wp_submenu_nopriv;
global $_wp_menu_nopriv;
- $file = plugin_basename($file);
+ $file = plugin_basename( $file );
- $parent = plugin_basename($parent);
- if ( isset($_wp_real_parent_file[$parent]) )
+ $parent = plugin_basename( $parent);
+ if ( isset( $_wp_real_parent_file[$parent] ) )
$parent = $_wp_real_parent_file[$parent];
- if ( !current_user_can($access_level) ) {
+ if ( !current_user_can( $access_level ) ) {
$_wp_submenu_nopriv[$parent][$file] = true;
return false;
}
@@ -1549,75 +1560,74 @@ function add_submenu_page($parent, $page_title, $menu_title, $access_level, $fil
// as the first item in the submenu. If the submenu file is the same as the
// parent file someone is trying to link back to the parent manually. In
// this case, don't automatically add a link back to avoid duplication.
- if (!isset ($submenu[$parent]) && $file != $parent ) {
- foreach ($menu as $parent_menu) {
- if ( $parent_menu[2] == $parent && current_user_can($parent_menu[1]) ) {
+ if (!isset( $submenu[$parent] ) && $file != $parent ) {
+ foreach ( $menu as $parent_menu ) {
+ if ( $parent_menu[2] == $parent && current_user_can( $parent_menu[1] ) )
$submenu[$parent][] = $parent_menu;
- }
}
}
- $submenu[$parent][] = array ($menu_title, $access_level, $file, $page_title);
+ $submenu[$parent][] = array ( $menu_title, $access_level, $file, $page_title );
- $hookname = get_plugin_page_hookname($file, $parent);
- if (!empty ($function) && !empty ($hookname))
- add_action($hookname, $function);
+ $hookname = get_plugin_page_hookname( $file, $parent);
+ if (!empty ( $function ) && !empty ( $hookname ))
+ add_action( $hookname, $function );
return $hookname;
}
-function add_options_page($page_title, $menu_title, $access_level, $file, $function = '') {
- return add_submenu_page('options-general.php', $page_title, $menu_title, $access_level, $file, $function);
+function add_options_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'options-general.php', $page_title, $menu_title, $access_level, $file, $function );
}
-function add_management_page($page_title, $menu_title, $access_level, $file, $function = '') {
- return add_submenu_page('edit.php', $page_title, $menu_title, $access_level, $file, $function);
+function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function );
}
-function add_theme_page($page_title, $menu_title, $access_level, $file, $function = '') {
- return add_submenu_page('themes.php', $page_title, $menu_title, $access_level, $file, $function);
+function add_theme_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'themes.php', $page_title, $menu_title, $access_level, $file, $function );
}
-function validate_file($file, $allowed_files = '') {
- if (false !== strpos($file, './'))
+function validate_file( $file, $allowed_files = '' ) {
+ if ( false !== strpos( $file, './' ))
return 1;
- if (':' == substr($file, 1, 1))
+ if (':' == substr( $file, 1, 1 ))
return 2;
- if (!empty ($allowed_files) && (!in_array($file, $allowed_files)))
+ if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
return 3;
return 0;
}
-function validate_file_to_edit($file, $allowed_files = '') {
- $file = stripslashes($file);
+function validate_file_to_edit( $file, $allowed_files = '' ) {
+ $file = stripslashes( $file );
- $code = validate_file($file, $allowed_files);
+ $code = validate_file( $file, $allowed_files );
- if (!$code)
+ if (!$code )
return $file;
- switch ($code) {
+ switch ( $code ) {
case 1 :
- wp_die(__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
+ wp_die( __('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.' ));
case 2 :
- wp_die(__('Sorry, can&#8217;t call files with their real path.'));
+ wp_die( __('Sorry, can&#8217;t call files with their real path.' ));
case 3 :
- wp_die(__('Sorry, that file cannot be edited.'));
+ wp_die( __('Sorry, that file cannot be edited.' ));
}
}
function get_home_path() {
- $home = get_option('home');
- if ($home != '' && $home != get_option('siteurl')) {
- $home_path = parse_url($home);
+ $home = get_option( 'home' );
+ if ( $home != '' && $home != get_option( 'siteurl' ) ) {
+ $home_path = parse_url( $home );
$home_path = $home_path['path'];
- $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]);
- $home_path = trailingslashit($root.$home_path);
+ $root = str_replace( $_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"] );
+ $home_path = trailingslashit( $root.$home_path );
} else {
$home_path = ABSPATH;
}
@@ -1625,8 +1635,8 @@ function get_home_path() {
return $home_path;
}
-function get_real_file_to_edit($file) {
- if ('index.php' == $file || '.htaccess' == $file) {
+function get_real_file_to_edit( $file ) {
+ if ('index.php' == $file || '.htaccess' == $file ) {
$real_file = get_home_path().$file;
} else {
$real_file = ABSPATH.$file;
@@ -1635,74 +1645,74 @@ function get_real_file_to_edit($file) {
return $real_file;
}
-$wp_file_descriptions = array ('index.php' => __('Main Index Template'), 'style.css' => __('Stylesheet'), 'comments.php' => __('Comments'), 'comments-popup.php' => __('Popup Comments'), 'footer.php' => __('Footer'), 'header.php' => __('Header'), 'sidebar.php' => __('Sidebar'), 'archive.php' => __('Archives'), 'category.php' => __('Category Template'), 'page.php' => __('Page Template'), 'search.php' => __('Search Results'), 'single.php' => __('Single Post'), '404.php' => __('404 Template'), 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), '.htaccess' => __('.htaccess (for rewrite rules)'),
+$wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ),
// Deprecated files
- 'wp-layout.css' => __('Stylesheet'), 'wp-comments.php' => __('Comments Template'), 'wp-comments-popup.php' => __('Popup Comments Template'));
+ 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' ));
-function get_file_description($file) {
+function get_file_description( $file ) {
global $wp_file_descriptions;
- if (isset ($wp_file_descriptions[basename($file)])) {
- return $wp_file_descriptions[basename($file)];
+ if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
+ return $wp_file_descriptions[basename( $file )];
}
elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
- $template_data = implode('', file( ABSPATH . $file ));
- if (preg_match("|Template Name:(.*)|i", $template_data, $name))
+ $template_data = implode( '', file( ABSPATH . $file ) );
+ if ( preg_match( "|Template Name:(.* )|i", $template_data, $name ))
return $name[1];
}
- return basename($file);
+ return basename( $file );
}
-function update_recently_edited($file) {
- $oldfiles = (array) get_option('recently_edited');
- if ($oldfiles) {
- $oldfiles = array_reverse($oldfiles);
+function update_recently_edited( $file ) {
+ $oldfiles = (array ) get_option( 'recently_edited' );
+ if ( $oldfiles ) {
+ $oldfiles = array_reverse( $oldfiles );
$oldfiles[] = $file;
- $oldfiles = array_reverse($oldfiles);
- $oldfiles = array_unique($oldfiles);
- if (5 < count($oldfiles))
- array_pop($oldfiles);
+ $oldfiles = array_reverse( $oldfiles );
+ $oldfiles = array_unique( $oldfiles );
+ if ( 5 < count( $oldfiles ))
+ array_pop( $oldfiles );
} else {
$oldfiles[] = $file;
}
- update_option('recently_edited', $oldfiles);
+ update_option( 'recently_edited', $oldfiles );
}
-function get_plugin_data($plugin_file) {
- $plugin_data = implode('', file($plugin_file));
- preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name);
- preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri);
- preg_match("|Description:(.*)|i", $plugin_data, $description);
- preg_match("|Author:(.*)|i", $plugin_data, $author_name);
- preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
- if (preg_match("|Version:(.*)|i", $plugin_data, $version))
- $version = trim($version[1]);
+function get_plugin_data( $plugin_file ) {
+ $plugin_data = implode( '', file( $plugin_file ));
+ preg_match( "|Plugin Name:(.*)|i", $plugin_data, $plugin_name );
+ preg_match( "|Plugin URI:(.*)|i", $plugin_data, $plugin_uri );
+ preg_match( "|Description:(.*)|i", $plugin_data, $description );
+ preg_match( "|Author:(.*)|i", $plugin_data, $author_name );
+ preg_match( "|Author URI:(.*)|i", $plugin_data, $author_uri );
+ if ( preg_match( "|Version:(.*)|i", $plugin_data, $version ))
+ $version = trim( $version[1] );
else
$version = '';
- $description = wptexturize(trim($description[1]));
+ $description = wptexturize( trim( $description[1] ));
$name = $plugin_name[1];
- $name = trim($name);
+ $name = trim( $name );
$plugin = $name;
- if ('' != $plugin_uri[1] && '' != $name) {
- $plugin = '<a href="' . trim($plugin_uri[1]) . '" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
+ if ('' != $plugin_uri[1] && '' != $name ) {
+ $plugin = '<a href="' . trim( $plugin_uri[1] ) . '" title="'.__( 'Visit plugin homepage' ).'">'.$plugin.'</a>';
}
- if ('' == $author_uri[1]) {
- $author = trim($author_name[1]);
+ if ('' == $author_uri[1] ) {
+ $author = trim( $author_name[1] );
} else {
- $author = '<a href="' . trim($author_uri[1]) . '" title="'.__('Visit author homepage').'">' . trim($author_name[1]) . '</a>';
+ $author = '<a href="' . trim( $author_uri[1] ) . '" title="'.__( 'Visit author homepage' ).'">' . trim( $author_name[1] ) . '</a>';
}
- return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]);
+ return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1] );
}
function get_plugins() {
global $wp_plugins;
- if (isset ($wp_plugins)) {
+ if ( isset( $wp_plugins ) ) {
return $wp_plugins;
}
@@ -1710,23 +1720,23 @@ function get_plugins() {
$plugin_root = ABSPATH . PLUGINDIR;
// Files in wp-content/plugins directory
- $plugins_dir = @ dir($plugin_root);
- if ($plugins_dir) {
- while (($file = $plugins_dir->read()) !== false) {
- if (preg_match('|^\.+$|', $file))
+ $plugins_dir = @ dir( $plugin_root);
+ if ( $plugins_dir ) {
+ while (($file = $plugins_dir->read() ) !== false ) {
+ if ( preg_match( '|^\.+$|', $file ))
continue;
- if (is_dir($plugin_root.'/'.$file)) {
- $plugins_subdir = @ dir($plugin_root.'/'.$file);
- if ($plugins_subdir) {
- while (($subfile = $plugins_subdir->read()) !== false) {
- if (preg_match('|^\.+$|', $subfile))
+ if ( is_dir( $plugin_root.'/'.$file ) ) {
+ $plugins_subdir = @ dir( $plugin_root.'/'.$file );
+ if ( $plugins_subdir ) {
+ while (($subfile = $plugins_subdir->read() ) !== false ) {
+ if ( preg_match( '|^\.+$|', $subfile ))
continue;
- if (preg_match('|\.php$|', $subfile))
+ if ( preg_match( '|\.php$|', $subfile ))
$plugin_files[] = "$file/$subfile";
}
}
} else {
- if (preg_match('|\.php$|', $file))
+ if ( preg_match( '|\.php$|', $file ))
$plugin_files[] = $file;
}
}
@@ -1736,72 +1746,72 @@ function get_plugins() {
return $wp_plugins;
foreach ( $plugin_files as $plugin_file ) {
- if ( !is_readable("$plugin_root/$plugin_file") )
+ if ( !is_readable( "$plugin_root/$plugin_file" ) )
continue;
- $plugin_data = get_plugin_data("$plugin_root/$plugin_file");
+ $plugin_data = get_plugin_data( "$plugin_root/$plugin_file" );
- if ( empty ($plugin_data['Name']) )
+ if ( empty ( $plugin_data['Name'] ) )
continue;
- $wp_plugins[plugin_basename($plugin_file)] = $plugin_data;
+ $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
}
- uasort($wp_plugins, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));
+ uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
return $wp_plugins;
}
-function get_plugin_page_hookname($plugin_page, $parent_page) {
+function get_plugin_page_hookname( $plugin_page, $parent_page ) {
global $admin_page_hooks;
$parent = get_admin_page_parent();
- if (empty ($parent_page) || 'admin.php' == $parent_page) {
- if (isset ($admin_page_hooks[$plugin_page]))
+ if ( empty ( $parent_page ) || 'admin.php' == $parent_page ) {
+ if ( isset( $admin_page_hooks[$plugin_page] ))
$page_type = 'toplevel';
else
- if (isset ($admin_page_hooks[$parent]))
+ if ( isset( $admin_page_hooks[$parent] ))
$page_type = $admin_page_hooks[$parent];
} else
- if (isset ($admin_page_hooks[$parent_page])) {
+ if ( isset( $admin_page_hooks[$parent_page] ) ) {
$page_type = $admin_page_hooks[$parent_page];
} else {
$page_type = 'admin';
}
- $plugin_name = preg_replace('!\.php!', '', $plugin_page);
+ $plugin_name = preg_replace( '!\.php!', '', $plugin_page );
return $page_type.'_page_'.$plugin_name;
}
-function get_plugin_page_hook($plugin_page, $parent_page) {
+function get_plugin_page_hook( $plugin_page, $parent_page ) {
global $wp_filter;
- $hook = get_plugin_page_hookname($plugin_page, $parent_page);
- if (isset ($wp_filter[$hook]))
+ $hook = get_plugin_page_hookname( $plugin_page, $parent_page );
+ if ( isset( $wp_filter[$hook] ))
return $hook;
else
return '';
}
function browse_happy() {
- $getit = __('WordPress recommends a better browser');
+ $getit = __( 'WordPress recommends a better browser' );
echo '
<p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p>
';
}
-if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
- add_action('admin_footer', 'browse_happy');
+if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ))
+ add_action( 'admin_footer', 'browse_happy' );
-function documentation_link($for) {
+function documentation_link( $for ) {
return;
}
-function register_importer($id, $name, $description, $callback) {
+function register_importer( $id, $name, $description, $callback ) {
global $wp_importers;
- $wp_importers[$id] = array ($name, $description, $callback);
+ $wp_importers[$id] = array ( $name, $description, $callback );
}
function get_importers() {
@@ -1830,14 +1840,14 @@ function current_theme_info() {
// array wp_handle_upload ( array &file [, array overrides] )
// file: reference to a single element of $_FILES. Call the function once for each uploaded file.
-// overrides: an associative array of names=>values to override default variables with extract($overrides, EXTR_OVERWRITE).
+// overrides: an associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
// On success, returns an associative array of file attributes.
-// On failure, returns $overrides['upload_error_handler'](&$file, $message) or array('error'=>$message).
-function wp_handle_upload(&$file, $overrides = false) {
+// On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
+function wp_handle_upload( &$file, $overrides = false ) {
// The default error handler.
- if (! function_exists('wp_handle_upload_error') ) {
- function wp_handle_upload_error(&$file, $message) {
- return array('error'=>$message);
+ if (! function_exists( 'wp_handle_upload_error' ) ) {
+ function wp_handle_upload_error( &$file, $message ) {
+ return array( 'error'=>$message );
}
}
@@ -1848,13 +1858,13 @@ function wp_handle_upload(&$file, $overrides = false) {
$action = 'wp_handle_upload';
// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
- $upload_error_strings = array(false,
- __("The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>."),
- __("The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form."),
- __("The uploaded file was only partially uploaded."),
- __("No file was uploaded."),
- __("Missing a temporary folder."),
- __("Failed to write file to disk."));
+ $upload_error_strings = array( false,
+ __( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ),
+ __( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ),
+ __( "The uploaded file was only partially uploaded." ),
+ __( "No file was uploaded." ),
+ __( "Missing a temporary folder." ),
+ __( "Failed to write file to disk." ));
// All tests are on by default. Most can be turned off by $override[{test_name}] = false;
$test_form = true;
@@ -1864,93 +1874,93 @@ function wp_handle_upload(&$file, $overrides = false) {
$test_type = true;
// Install user overrides. Did we mention that this voids your warranty?
- if ( is_array($overrides) )
- extract($overrides, EXTR_OVERWRITE);
+ if ( is_array( $overrides ) )
+ extract( $overrides, EXTR_OVERWRITE );
// A correct form post will pass this test.
- if ( $test_form && (!isset($_POST['action']) || ($_POST['action'] != $action)) )
- return $upload_error_handler($file, __('Invalid form submission.'));
+ if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
+ return $upload_error_handler( $file, __( 'Invalid form submission.' ));
// A successful upload will pass this test. It makes no sense to override this one.
if ( $file['error'] > 0 )
- return $upload_error_handler($file, $upload_error_strings[$file['error']]);
+ return $upload_error_handler( $file, $upload_error_strings[$file['error']] );
// A non-empty file will pass this test.
- if ( $test_size && !($file['size'] > 0) )
- return $upload_error_handler($file, __('File is empty. Please upload something more substantial.'));
+ if ( $test_size && !($file['size'] > 0 ) )
+ return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial.' ));
// A properly uploaded file will pass this test. There should be no reason to override this one.
- if (! @ is_uploaded_file($file['tmp_name']) )
- return $upload_error_handler($file, __('Specified file failed upload test.'));
+ if (! @ is_uploaded_file( $file['tmp_name'] ) )
+ return $upload_error_handler( $file, __( 'Specified file failed upload test.' ));
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
if ( $test_type ) {
- $wp_filetype = wp_check_filetype($file['name'], $mimes);
+ $wp_filetype = wp_check_filetype( $file['name'], $mimes );
- extract($wp_filetype);
+ extract( $wp_filetype );
if ( !$type || !$ext )
- return $upload_error_handler($file, __('File type does not meet security guidelines. Try another.'));
+ return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' ));
}
- // A writable uploads dir will pass this test. Override with $uploads = array('path'=>$path, 'url'=>$url);
- if ( ( empty( $uploads['path'] ) || empty( $uploads['url'] ) ) && ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
- return $upload_error_handler($file, $uploads['error']);
+ // A writable uploads dir will pass this test. Again, there's no point overriding this one.
+ if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+ return $upload_error_handler( $file, $uploads['error'] );
// Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied.
- if ( isset($unique_filename_callback) && function_exists($unique_filename_callback) ) {
- $filename = $unique_filename_callback($uploads['path'], $file['name']);
+ if ( isset( $unique_filename_callback ) && function_exists( $unique_filename_callback ) ) {
+ $filename = $unique_filename_callback( $uploads['path'], $file['name'] );
} else {
$number = '';
- $filename = str_replace('#', '_', $file['name']);
- $filename = str_replace(array('\\', "'"), '', $filename);
- if ( empty($ext) )
+ $filename = str_replace( '#', '_', $file['name'] );
+ $filename = str_replace( array( '\\', "'" ), '', $filename );
+ if ( empty( $ext) )
$ext = '';
else
$ext = ".$ext";
- while ( file_exists($uploads['path'] . "/$filename") ) {
+ while ( file_exists( $uploads['path'] . "/$filename" ) ) {
if ( '' == "$number$ext" )
$filename = $filename . ++$number . $ext;
else
- $filename = str_replace("$number$ext", ++$number . $ext, $filename);
+ $filename = str_replace( "$number$ext", ++$number . $ext, $filename );
}
- $filename = str_replace($ext, '', $filename);
- $filename = sanitize_title_with_dashes($filename) . $ext;
+ $filename = str_replace( $ext, '', $filename );
+ $filename = sanitize_title_with_dashes( $filename ) . $ext;
}
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
- if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) )
- wp_die(printf(__('The uploaded file could not be moved to %s.'), $uploads['path']));
+ if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
+ wp_die( printf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ));
// Set correct file permissions
- $stat = stat(dirname($new_file));
+ $stat = stat( dirname( $new_file ));
$perms = $stat['mode'] & 0000666;
- @ chmod($new_file, $perms);
+ @ chmod( $new_file, $perms );
// Compute the URL
$url = $uploads['url'] . "/$filename";
- $return = apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) );
+ $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) );
return $return;
}
-function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) {
+function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
if ( $height <= $hmax && $width <= $wmax )
- return array($width, $height);
+ return array( $width, $height);
elseif ( $width / $height > $wmax / $hmax )
- return array($wmax, (int) ($height / $width * $wmax));
+ return array( $wmax, (int) ($height / $width * $wmax ));
else
- return array((int) ($width / $height * $hmax), $hmax);
+ return array( (int) ($width / $height * $hmax ), $hmax );
}
-function wp_import_cleanup($id) {
- wp_delete_attachment($id);
+function wp_import_cleanup( $id ) {
+ wp_delete_attachment( $id );
}
-function wp_import_upload_form($action) {
- $size = strtolower( ini_get('upload_max_filesize') );
+function wp_import_upload_form( $action ) {
+ $size = strtolower( ini_get( 'upload_max_filesize' ) );
$bytes = 0;
if ( strstr( $size, 'k' ) )
$bytes = $size * 1024;
@@ -1961,79 +1971,78 @@ function wp_import_upload_form($action) {
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo $action ?>">
<p>
-<label for="upload"><?php _e('Choose a file from your computer:'); ?></label> (<?php printf( __('Maximum size: %s'), $size ); ?>)
+<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> )
<input type="file" id="upload" name="import" size="25" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
</p>
<p class="submit">
-<input type="submit" value="<?php _e('Upload file and import'); ?> &raquo;" />
+<input type="submit" value="<?php _e( 'Upload file and import' ); ?> &raquo;" />
</p>
</form>
<?php
}
function wp_import_handle_upload() {
- $overrides = array('test_form' => false, 'test_type' => false);
- $file = wp_handle_upload($_FILES['import'], $overrides);
+ $overrides = array( 'test_form' => false, 'test_type' => false );
+ $file = wp_handle_upload( $_FILES['import'], $overrides );
- if ( isset($file['error']) )
+ if ( isset( $file['error'] ) )
return $file;
$url = $file['url'];
$file = addslashes( $file['file'] );
- $filename = basename($file);
+ $filename = basename( $file );
// Construct the object array
- $object = array(
- 'post_title' => $filename,
+ $object = array( 'post_title' => $filename,
'post_content' => $url,
'post_mime_type' => 'import',
'guid' => $url
);
// Save the data
- $id = wp_insert_attachment($object, $file);
+ $id = wp_insert_attachment( $object, $file );
- return array('file' => $file, 'id' => $id);
+ return array( 'file' => $file, 'id' => $id );
}
-function the_attachment_links($id = false) {
+function the_attachment_links( $id = false ) {
$id = (int) $id;
- $post = & get_post($id);
+ $post = & get_post( $id );
if ( $post->post_type != 'attachment' )
return false;
- $icon = get_attachment_icon($post->ID);
+ $icon = get_attachment_icon( $post->ID );
$attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
- $thumb = isset($attachment_data['thumb']);
+ $thumb = isset( $attachment_data['thumb'] );
?>
<form id="the-attachment-links">
<table>
<col />
<col class="widefat" />
<tr>
- <th scope="row"><?php _e('URL') ?></th>
+ <th scope="row"><?php _e( 'URL' ) ?></th>
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo $post->guid ?></textarea></td>
</tr>
<?php if ( $icon ) : ?>
<tr>
- <th scope="row"><?php $thumb ? _e('Thumbnail linked to file') : _e('Image linked to file'); ?></th>
+ <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid; ?>"><?php echo $icon ?></a></textarea></td>
</tr>
<tr>
- <th scope="row"><?php $thumb ? _e('Thumbnail linked to page') : _e('Image linked to file'); ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
+ <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to file' ); ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
</tr>
<?php else : ?>
<tr>
- <th scope="row"><?php _e('Link to file') ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid); ?></a></textarea></td>
+ <th scope="row"><?php _e( 'Link to file' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename( $post->guid ); ?></a></textarea></td>
</tr>
<tr>
- <th scope="row"><?php _e('Link to page') ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
+ <th scope="row"><?php _e( 'Link to page' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
</tr>
<?php endif; ?>
</table>
@@ -2041,23 +2050,23 @@ function the_attachment_links($id = false) {
<?php
}
-function get_udims($width, $height) {
+function get_udims( $width, $height) {
if ( $height <= 96 && $width <= 128 )
- return array($width, $height);
+ return array( $width, $height);
elseif ( $width / $height > 4 / 3 )
- return array(128, (int) ($height / $width * 128));
+ return array( 128, (int) ($height / $width * 128 ));
else
- return array((int) ($width / $height * 96), 96);
+ return array( (int) ($width / $height * 96 ), 96 );
}
-function wp_reset_vars($vars) {
- for ($i=0; $i<count($vars); $i += 1) {
+function wp_reset_vars( $vars ) {
+ for ( $i=0; $i<count( $vars ); $i += 1 ) {
$var = $vars[$i];
global $$var;
- if (!isset($$var)) {
- if (empty($_POST["$var"])) {
- if (empty($_GET["$var"]))
+ if (!isset( $$var ) ) {
+ if ( empty( $_POST["$var"] ) ) {
+ if ( empty( $_GET["$var"] ) )
$$var = '';
else
$$var = $_GET["$var"];
@@ -2069,10 +2078,10 @@ function wp_reset_vars($vars) {
}
// If siteurl or home changed, reset cookies and flush rewrite rules.
-function update_home_siteurl($old_value, $value) {
+function update_home_siteurl( $old_value, $value ) {
global $wp_rewrite, $user_login, $user_pass_md5;
- if ( defined("WP_INSTALLING") )
+ if ( defined( "WP_INSTALLING" ) )
return;
// If home changed, write rewrite rules to new location.
@@ -2080,11 +2089,58 @@ function update_home_siteurl($old_value, $value) {
// Clear cookies for old paths.
wp_clearcookie();
// Set cookies for new paths.
- wp_setcookie($user_login, $user_pass_md5, true, get_option('home'), get_option('siteurl'));
+ wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' ));
+}
+
+add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
+add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
+
+function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
+ if ( ctype_digit( $src_file ) ) // Handle int as attachment ID
+ $src_file = get_attached_file( $src_file );
+
+ $src = wp_load_image( $src_file );
+
+ if ( !is_resource( $src ))
+ return $src;
+
+ $dst = imagecreatetruecolor( $dst_w, $dst_h );
+
+ if ( $src_abs ) {
+ $src_w -= $src_x;
+ $src_h -= $src_y;
+ }
+
+ imageantialias( $dst, true );
+ imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
+
+ if ( !$dst_file )
+ $dst_file = str_replace( basename( $src_file ), 'cropped-'.basename( $src_file ), $src_file );
+
+ $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file );
+
+ if ( imagejpeg( $dst, $dst_file ) )
+ return $dst_file;
+ else
+ return false;
}
-add_action('update_option_home', 'update_home_siteurl', 10, 2);
-add_action('update_option_siteurl', 'update_home_siteurl', 10, 2);
+function wp_load_image( $file ) {
+ if ( ctype_digit( $file ) )
+ $file = get_attached_file( $file );
+
+ if ( !file_exists( $file ) )
+ return "File '$file' doesn't exist?";
+
+ $contents = file_get_contents( $file );
+
+ $image = imagecreatefromstring( $contents );
+
+ if ( !is_resource( $image ) )
+ return "File '$file' is not image?";
+
+ return $image;
+}
function autocomplete_css() {
?>
@@ -2163,52 +2219,4 @@ The Webmaster" );
}
add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
-
-function wp_crop_image($src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false) {
- if ( ctype_digit($src_file) ) // Handle int as attachment ID
- $src_file = get_attached_file($src_file);
-
- $src = wp_load_image($src_file);
-
- if ( !is_resource($src) )
- return $src;
-
- $dst = imagecreatetruecolor($dst_w, $dst_h);
-
- if ( $src_abs ) {
- $src_w -= $src_x;
- $src_h -= $src_y;
- }
-
- imageantialias($dst, true);
- imagecopyresampled($dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
-
- if ( !$dst_file )
- $dst_file = str_replace(basename($src_file), 'cropped-'.basename($src_file), $src_file);
-
- $dst_file = preg_replace('/\\.[^\\.]+$/', '.jpg', $dst_file);
-
- if ( imagejpeg($dst, $dst_file) )
- return $dst_file;
- else
- return false;
-}
-
-function wp_load_image($file) {
- if ( ctype_digit($file) )
- $file = get_attached_file($file);
-
- if ( !file_exists($file) )
- return "File '$file' doesn't exist?";
-
- $contents = file_get_contents($file);
-
- $image = imagecreatefromstring($contents);
-
- if ( !is_resource($image) )
- return "File '$file' is not image?";
-
- return $image;
-}
-
?>
diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php
index 663efa9..30afb3a 100644
--- a/wp-admin/admin-header.php
+++ b/wp-admin/admin-header.php
@@ -16,7 +16,7 @@ get_admin_page_title();
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
-<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
+<title><?php bloginfo('name') ?> &rsaquo; <?php echo wp_specialchars( strip_tags( $title ) ); ?> &#8212; WordPress</title>
<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
diff --git a/wp-admin/bookmarklet.php b/wp-admin/bookmarklet.php
index 417d910..def516e 100644
--- a/wp-admin/bookmarklet.php
+++ b/wp-admin/bookmarklet.php
@@ -35,16 +35,16 @@ if (!empty($post_title))
else
$post->post_title = $popuptitle;
-
+
$content = wp_specialchars($_REQUEST['content']);
$popupurl = wp_specialchars($_REQUEST['popupurl']);
- if ( !empty($content) ) {
- $post->post_content = wp_specialchars( stripslashes($_REQUEST['content']) );
- } else {
- $post->post_content = '<a href="'.$popupurl.'">'.$popuptitle.'</a>'."\n$text";
- }
+if ( !empty($content) ) {
+ $post->post_content = wp_specialchars( stripslashes($_REQUEST['content']) );
+} else {
+ $post->post_content = '<a href="'.$popupurl.'">'.$popuptitle.'</a>'."\n$text";
+}
- /* /big funky fixes */
+/* /big funky fixes */
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -77,15 +77,15 @@ $popupurl = wp_specialchars($_REQUEST['popupurl']);
}
#wpbookmarklet .wrap {
- border: 0px;
+ border: 0px;
}
#wpbookmarklet #postdiv {
- margin-bottom: 0.5em;
+ margin-bottom: 0.5em;
}
#wpbookmarklet #titlediv {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
-->
diff --git a/wp-admin/categories.php b/wp-admin/categories.php
index 58c0188..0bdd68f 100644
--- a/wp-admin/categories.php
+++ b/wp-admin/categories.php
@@ -20,6 +20,7 @@ case 'addcat':
} else {
wp_redirect('categories.php?message=4#addcat');
}
+ exit;
break;
case 'delete':
@@ -36,20 +37,21 @@ case 'delete':
wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
if ( $cat_ID == get_option('default_link_category') )
- wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name));
+ wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for links"), $cat_name));
wp_delete_category($cat_ID);
wp_redirect('categories.php?message=2');
+ exit;
break;
case 'edit':
- require_once ('admin-header.php');
- $cat_ID = (int) $_GET['cat_ID'];
- $category = get_category_to_edit($cat_ID);
- include('edit-category-form.php');
+ require_once ('admin-header.php');
+ $cat_ID = (int) $_GET['cat_ID'];
+ $category = get_category_to_edit($cat_ID);
+ include('edit-category-form.php');
break;
@@ -60,9 +62,12 @@ case 'editedcat':
if ( !current_user_can('manage_categories') )
wp_die(__('Cheatin&#8217; uh?'));
- wp_update_category($_POST);
+ if ( wp_update_category($_POST) )
+ wp_redirect('categories.php?message=3');
+ else
+ wp_redirect('categories.php?message=5');
- wp_redirect('categories.php?message=3');
+ exit;
break;
default:
@@ -74,6 +79,7 @@ $messages[1] = __('Category added.');
$messages[2] = __('Category deleted.');
$messages[3] = __('Category updated.');
$messages[4] = __('Category not added.');
+$messages[5] = __('Category not updated.');
?>
<?php if (isset($_GET['message'])) : ?>
@@ -93,7 +99,7 @@ $messages[4] = __('Category not added.');
<th scope="col"><?php _e('Name') ?></th>
<th scope="col"><?php _e('Description') ?></th>
<th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
- <th scope="col" width="90" style="text-align: center"><?php _e('Bookmarks') ?></th>
+ <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
<th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
</tr>
</thead>
@@ -108,8 +114,7 @@ cat_rows();
<?php if ( current_user_can('manage_categories') ) : ?>
<div class="wrap">
-<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
-<p><?php _e('<strong>Also Note:</strong><br />Categories will appear on your blog once you have posted something in them. Empty categories remain invisible.'); ?></p>
+<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and links in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and links are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
</div>
<?php include('edit-category-form.php'); ?>
diff --git a/wp-admin/comment.php b/wp-admin/comment.php
index 065bd39..8ce3cd8 100644
--- a/wp-admin/comment.php
+++ b/wp-admin/comment.php
@@ -202,7 +202,7 @@ case 'editedcomment':
$location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID;
$location = apply_filters('comment_edit_redirect', $location, $comment_ID);
wp_redirect($location);
-
+ exit();
break;
default:
break;
diff --git a/wp-admin/custom-fields.js b/wp-admin/custom-fields.js
index a48661f..ad7a2db 100644
--- a/wp-admin/custom-fields.js
+++ b/wp-admin/custom-fields.js
@@ -14,10 +14,10 @@ function customFieldsAddIn() {
for ( var i=0; i < inputs.length; i++ ) {
if ('text' == inputs[i].type) {
inputs[i].setAttribute('autocomplete', 'off');
- inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); };
+ inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); };
}
if ('updatemeta' == inputs[i].className) {
- inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); };
+ inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); };
}
}
diff --git a/wp-admin/dbx-admin-key-js.php b/wp-admin/dbx-admin-key-js.php
index f47e53b..9746a8c 100644
--- a/wp-admin/dbx-admin-key-js.php
+++ b/wp-admin/dbx-admin-key-js.php
@@ -9,7 +9,7 @@ switch ( $_GET['pagenow'] ) :
break;
case 'page.php' :
case 'page-new.php' :
- $man = 'pagemeta';
+ $man = 'pagemeta';
break;
case 'link.php' :
$man = 'linkmeta';
diff --git a/wp-admin/edit-category-form.php b/wp-admin/edit-category-form.php
index 66581ae..fece01f 100644
--- a/wp-admin/edit-category-form.php
+++ b/wp-admin/edit-category-form.php
@@ -40,5 +40,6 @@ if ( ! empty($cat_ID) ) {
<?php autocomplete_textbox( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?>
<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
<div id="ajax-response"></div>
+<?php do_action('edit_category_form', $category); ?>
</form>
</div>
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index 6227ef7..488a055 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -2,7 +2,7 @@
require_once('admin.php');
$title = __('Edit Comments');
-$parent_file = 'edit.php';
+$parent_file = 'edit-comments.php';
wp_enqueue_script( 'admin-comments' );
require_once('admin-header.php');
@@ -85,19 +85,57 @@ if (isset($_GET['s'])) {
comment_approved != 'spam'
ORDER BY comment_date DESC");
} else {
- if ( isset($_GET['offset']) )
- $offset = (int) $_GET['offset'] * 20;
+ if ( isset( $_GET['apage'] ) )
+ $page = (int) $_GET['apage'];
else
- $offset = 0;
+ $page = 1;
+ $start = $offset = ( $page - 1 ) * 20;
+ $end = $start + 20;
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20");
+ $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $end" );
+ $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1'" );
}
+?>
+<?php if ( $total > 20 ) {
+$total_pages = ceil( $total / 20 );
+$r = '';
+if ( 1 < $page ) {
+ $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1;
+ $r .= '<a class="prev" href="' . add_query_arg( $args ) . '">&laquo; '. __('Previous Page') .'</a>' . "\n";
+}
+if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) {
+ for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
+ if ( $page == $page_num ) :
+ $r .= "<span>$page_num</span>\n";
+ else :
+ $p = false;
+ if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
+ $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num;
+ $r .= '<a class="page-numbers" href="' . add_query_arg($args) . '">' . ( $page_num ) . "</a>\n";
+ $in = true;
+ elseif ( $in == true ) :
+ $r .= "...\n";
+ $in = false;
+ endif;
+ endif;
+ endfor;
+}
+if ( ( $page ) * 20 < $total || -1 == $total ) {
+ $args['apage'] = $page + 1;
+ $r .= '<a class="next" href="' . add_query_arg($args) . '">'. __('Next Page') .' &raquo;</a>' . "\n";
+}
+echo "<p>$r</p>";
+?>
+
+<?php } ?>
+
+<?php
if ('view' == $mode) {
if ($comments) {
- if ($offset)
- $start = " start='$offset'";
- else
- $start = '';
+?>
+<?php
+$offset = $offset + 1;
+$start = " start='$offset'";
echo "<ol id='the-comment-list' class='commentlist' $start>";
$i = 0;
@@ -105,7 +143,7 @@ if ('view' == $mode) {
++$i; $class = '';
$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
$comment_status = wp_get_comment_status($comment->comment_ID);
- if ('unapproved' == $comment_status)
+ if ('unapproved' == $comment_status)
$class .= ' unapproved';
if ($i % 2)
$class .= ' alternate';
@@ -115,7 +153,7 @@ if ('view' == $mode) {
<?php comment_text() ?>
-<p><?php comment_date('M j, g:i A'); ?> &#8212; [
+<p><?php comment_date('M j, g:i A'); ?> &#8212; [
<?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>';
@@ -143,7 +181,7 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
?>
<p>
- <strong><?php _e('No comments found.') ?></strong></p>
+ <strong><?php _e('No comments found.') ?></strong></p>
<?php
} // end if ($comments)
@@ -205,6 +243,38 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
} // end if ($comments)
}
?>
+<?php if ( $total > 20 ) {
+$total_pages = ceil( $total / 20 );
+$r = '';
+if ( 1 < $page ) {
+ $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1;
+ $r .= '<a class="prev" href="' . add_query_arg( $args ) . '">&laquo; '. __('Previous Page') .'</a>' . "\n";
+}
+if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) {
+ for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
+ if ( $page == $page_num ) :
+ $r .= "<span>$page_num</span>\n";
+ else :
+ $p = false;
+ if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
+ $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num;
+ $r .= '<a class="page-numbers" href="' . add_query_arg($args) . '">' . ( $page_num ) . "</a>\n";
+ $in = true;
+ elseif ( $in == true ) :
+ $r .= "...\n";
+ $in = false;
+ endif;
+ endif;
+ endfor;
+}
+if ( ( $page ) * 20 < $total || -1 == $total ) {
+ $args['apage'] = $page + 1;
+ $r .= '<a class="next" href="' . add_query_arg($args) . '">'. __('Next Page') .' &raquo;</a>' . "\n";
+}
+echo "<p>$r</p>";
+?>
+
+<?php } ?>
</div>
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index c761b67..2b18d8e 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -8,8 +8,7 @@ $messages[3] = __('Custom field deleted.');
<?php endif; ?>
<form name="post" action="post.php" method="post" id="post">
-<?php if ( (isset($mode) && 'bookmarklet' == $mode) ||
- isset($_GET['popupurl']) ): ?>
+<?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
<input type="hidden" name="mode" value="bookmarklet" />
<?php endif; ?>
@@ -126,7 +125,7 @@ if ( $authors && count( $authors ) > 1 ) :
<h3 class="dbx-handle"><?php _e('Post Author'); ?>:</h3>
<div class="dbx-content">
<select name="post_author_override" id="post_author_override">
-<?php
+<?php
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"';
@@ -145,8 +144,8 @@ endforeach;
</div>
<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>
+ <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>
</fieldset>
<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
@@ -213,7 +212,7 @@ if (current_user_can('upload_files')) {
</div>
<div class="dbx-content-wrapper">
<div class="dbx-content"><?php _e('Send trackbacks to'); ?>: <?php echo $form_trackback; ?> (<?php _e('Separate multiple URIs with spaces'); ?>)
-<?php
+<?php
if ( ! empty($pings) )
echo $pings;
?>
@@ -232,7 +231,7 @@ if ( ! empty($pings) )
<table cellpadding="3">
<?php
$metadata = has_meta($post_ID);
-list_meta($metadata);
+list_meta($metadata);
?>
</table>
diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php
index 893e3f7..ac20ed7 100644
--- a/wp-admin/edit-form-comment.php
+++ b/wp-admin/edit-form-comment.php
@@ -54,8 +54,8 @@ addLoadEvent(focusit);
<tr>
<th scope="row" valign="top"><?php _e('Comment Status') ?>:</th>
<td><label for="comment_status_approved" class="selectit"><input id="comment_status_approved" name="comment_status" type="radio" value="1" <?php checked($comment->comment_approved, '1'); ?> /> <?php _e('Approved') ?></label><br />
- <label for="comment_status_moderated" class="selectit"><input id="comment_status_moderated" name="comment_status" type="radio" value="0" <?php checked($comment->comment_approved, '0'); ?> /> <?php _e('Moderated') ?></label><br />
- <label for="comment_status_spam" class="selectit"><input id="comment_status_spam" name="comment_status" type="radio" value="spam" <?php checked($comment->comment_approved, 'spam'); ?> /> <?php _e('Spam') ?></label></td>
+ <label for="comment_status_moderated" class="selectit"><input id="comment_status_moderated" name="comment_status" type="radio" value="0" <?php checked($comment->comment_approved, '0'); ?> /> <?php _e('Moderated') ?></label><br />
+ <label for="comment_status_spam" class="selectit"><input id="comment_status_spam" name="comment_status" type="radio" value="spam" <?php checked($comment->comment_approved, 'spam'); ?> /> <?php _e('Spam') ?></label></td>
</tr>
<?php if ( current_user_can('edit_posts') ) : ?>
diff --git a/wp-admin/edit-form.php b/wp-admin/edit-form.php
index 2d1cef6..d907a62 100644
--- a/wp-admin/edit-form.php
+++ b/wp-admin/edit-form.php
@@ -54,17 +54,17 @@ edCanvas = document.getElementById('content');
<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.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
<input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
-<p class="submit"><input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft') ?>" />
- <input name="saveasprivate" type="submit" id="saveasprivate" tabindex="10" value="<?php _e('Save as Private') ?>" />
+<p class="submit"><input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft') ?>" />
+ <input name="saveasprivate" type="submit" id="saveasprivate" tabindex="10" value="<?php _e('Save as Private') ?>" />
<?php if ( current_user_can('edit_posts') ) : ?>
- <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="<?php _e('Publish') ?>" />
+ <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="<?php _e('Publish') ?>" />
<?php endif; ?>
<?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()); ?>" />
+ 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()); ?>" />
</p>
<?php do_action('simple_edit_form', ''); ?>
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php
index ac9c831..4c0a714 100644
--- a/wp-admin/edit-link-form.php
+++ b/wp-admin/edit-link-form.php
@@ -30,7 +30,7 @@ function xfn_check($class, $value = '', $type = 'check') {
}
?>
-<div class="wrap">
+<div class="wrap">
<h2><?php echo $heading ?></h2>
<?php echo $form ?>
<?php wp_nonce_field($nonce_action); ?>
@@ -53,7 +53,7 @@ function xfn_check($class, $value = '', $type = 'check') {
</fieldset>
<fieldset class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Target') ?></h3>
+<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"' : ''); ?> />
@@ -68,7 +68,7 @@ function xfn_check($class, $value = '', $type = 'check') {
</fieldset>
<fieldset class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
+<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" />
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index ae52683..5f80f26 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -16,7 +16,7 @@ if (0 == $post_ID) {
$sendto = wp_get_referer();
if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
- $sendto = 'redo';
+ $sendto = 'redo';
$sendto = wp_specialchars( $sendto );
?>
@@ -27,7 +27,7 @@ $sendto = wp_specialchars( $sendto );
wp_nonce_field($nonce_action);
if (isset($mode) && 'bookmarklet' == $mode) {
- echo '<input type="hidden" name="mode" value="bookmarklet" />';
+ echo '<input type="hidden" name="mode" value="bookmarklet" />';
}
?>
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
@@ -103,7 +103,7 @@ addLoadEvent(focusit);
<h3 class="dbx-handle"><?php _e('Page Author'); ?>:</h3>
<div class="dbx-content">
<select name="post_author_override" id="post_author_override">
-<?php
+<?php
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"';
@@ -117,7 +117,7 @@ endforeach;
<?php endif; ?>
<fieldset id="pageorder" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Page Order') ?></h3>
+<h3 class="dbx-handle"><?php _e('Page Order') ?></h3>
<div class="dbx-content"><p><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p></div>
</fieldset>
@@ -168,9 +168,9 @@ if (current_user_can('upload_files')) {
<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
<div id="postcustomstuff" class="dbx-content">
<table cellpadding="3">
-<?php
+<?php
$metadata = has_meta($post_ID);
-list_meta($metadata);
+list_meta($metadata);
?>
</table>
@@ -186,7 +186,7 @@ list_meta($metadata);
</div>
<?php if ('edit' == $action) :
- $delete_nonce = wp_create_nonce( 'delete-page_' . $post_ID );
+ $delete_nonce = wp_create_nonce( 'delete-page_' . $post_ID );
if ( current_user_can('delete_page', $post->ID) ) ?>
<input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"if ( confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), js_escape($post->post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />
<?php endif; ?>
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php
index 721d5df..ca496ab 100644
--- a/wp-admin/edit-pages.php
+++ b/wp-admin/edit-pages.php
@@ -10,12 +10,12 @@ 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" action="" method="get">
- <fieldset>
- <legend><?php _e('Search Pages&hellip;') ?></legend>
- <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" />
- <input type="submit" name="submit" value="<?php _e('Search') ?>" />
- </fieldset>
+<form name="searchform" action="" method="get">
+ <fieldset>
+ <legend><?php _e('Search Pages&hellip;') ?></legend>
+ <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+ </fieldset>
</form>
<?php
@@ -53,10 +53,10 @@ page_rows(0, 0, $posts, $all);
<p><?php _e('No pages yet.') ?></p>
<?php
} // end if ($posts)
-?>
+?>
<h3><a href="page-new.php"><?php _e('Create New Page &raquo;'); ?></a></h3>
</div>
-<?php include('admin-footer.php'); ?>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/edit.php b/wp-admin/edit.php
index e96b6d0..395bc6b 100644
--- a/wp-admin/edit.php
+++ b/wp-admin/edit.php
@@ -12,11 +12,11 @@ $drafts = get_users_drafts( $user_ID );
$other_drafts = get_others_drafts( $user_ID);
if ($drafts || $other_drafts) {
-?>
+?>
<div class="wrap">
<?php if ($drafts) { ?>
- <p><strong><?php _e('Your Drafts:') ?></strong>
- <?php
+ <p><strong><?php _e('Your Drafts:') ?></strong>
+ <?php
$i = 0;
foreach ($drafts as $draft) {
if (0 != $i)
@@ -27,13 +27,13 @@ if ($drafts || $other_drafts) {
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
++$i;
}
- ?>
- .</p>
+ ?>
+ .</p>
<?php } ?>
-<?php if ($other_drafts) { ?>
- <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
- <?php
+<?php if ($other_drafts) { ?>
+ <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
+ <?php
$i = 0;
foreach ($other_drafts as $draft) {
if (0 != $i)
@@ -44,8 +44,8 @@ if ($drafts || $other_drafts) {
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
++$i;
}
- ?>
- .</p>
+ ?>
+ .</p>
<?php } ?>
@@ -88,7 +88,7 @@ if ( count($arc_result) ) { ?>
<form name="viewarc" id="viewarc" action="" method="get">
<fieldset>
<legend><?php _e('Browse Month&hellip;') ?></legend>
- <select name='m'>
+ <select name='m'>
<?php
foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 )
@@ -127,12 +127,12 @@ if ( count($arc_result) ) { ?>
<?php
// define the columns to display, the syntax is 'internal name' => 'display name'
$posts_columns = array(
- 'id' => __('ID'),
- 'date' => __('When'),
- 'title' => __('Title'),
- 'categories' => __('Categories'),
- 'comments' => __('Comments'),
- 'author' => __('Author')
+ 'id' => __('ID'),
+ 'date' => __('When'),
+ 'title' => __('Title'),
+ 'categories' => __('Categories'),
+ 'comments' => __('Comments'),
+ 'author' => __('Author')
);
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
@@ -143,7 +143,7 @@ $posts_columns['control_delete'] = '';
?>
-<table class="widefat">
+<table class="widefat">
<thead>
<tr>
@@ -157,10 +157,10 @@ $posts_columns['control_delete'] = '';
<?php
if ($posts) {
$bgcolor = '';
-foreach ($posts as $post) { start_wp();
+while (have_posts()) : the_post();
add_filter('the_title','wp_specialchars');
$class = ('alternate' == $class) ? '' : 'alternate';
-?>
+?>
<tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
<?php
@@ -177,7 +177,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'date':
?>
- <td><?php the_time('Y-m-d \<\b\r \/\> g:i:s a'); ?></td>
+ <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time('Y-m-d \<\b\r \/\> g:i:s a'); ?></td>
<?php
break;
case 'title':
@@ -195,9 +195,9 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'comments':
?>
- <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
- <?php comments_number(__('0'), __('1'), __('%')) ?>
- </a></td>
+ <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
+ <?php comments_number(__('0'), __('1'), __('%')) ?>
+ </a></td>
<?php
break;
@@ -235,7 +235,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
?>
</tr>
<?php
-}
+endwhile;
} else {
?>
<tr style='background-color: <?php echo $bgcolor; ?>'>
@@ -259,9 +259,9 @@ if ( 1 == count($posts) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
if ($comments) {
- ?>
-<h3 id="comments"><?php _e('Comments') ?></h3>
-<ol id="the-comment-list" class="commentlist">
+ ?>
+<h3 id="comments"><?php _e('Comments') ?></h3>
+<ol id="the-comment-list" class="commentlist">
<?php
$i = 0;
foreach ($comments as $comment) {
@@ -269,7 +269,7 @@ foreach ($comments as $comment) {
++$i; $class = '';
$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
$comment_status = wp_get_comment_status($comment->comment_ID);
- if ('unapproved' == $comment_status)
+ if ('unapproved' == $comment_status)
$class .= ' unapproved';
if ($i % 2)
$class .= ' alternate';
@@ -299,8 +299,8 @@ if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
echo '</ol>';
}//end if comments
?>
-<?php } ?>
-</div>
-<?php
+<?php } ?>
+</div>
+<?php
include('admin-footer.php');
-?>
+?>
diff --git a/wp-admin/export.php b/wp-admin/export.php
index f50b8e0..8f740fc 100644
--- a/wp-admin/export.php
+++ b/wp-admin/export.php
@@ -15,6 +15,25 @@ require_once ('admin-header.php');
<p><?php _e('When you click the button below WordPress will create a 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>
<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>
@@ -26,17 +45,35 @@ require_once ('admin-header.php');
<?php
function export_wp() {
- global $wpdb, $posts, $post;
- $filename = 'wordpress.' . date('Y-m-d') . '.xml';
+global $wpdb, $posts, $post;
+
+$filename = 'wordpress.' . date('Y-m-d') . '.xml';
+
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=$filename");
-header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
-//$posts = query_posts('');
-$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
+header('Content-type: text/wxr+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");
?>
+<!-- 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. -->
+<!-- To import this information into a WordPress blog, -->
+<!-- 1. Log into that blog as an administrator -->
+<!-- 2. Go to Manage: Import in the blog's admin panels -->
+<!-- 3. Choose "WordPress" from the list -->
+<!-- 4. Upload this file using the form provided on that page -->
+<!-- You will be taken through the simple import procedure. -->
+
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
-<rss version="2.0"
+<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/"
@@ -62,6 +99,7 @@ $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt A
<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>
@@ -71,7 +109,7 @@ $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt A
<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
<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");
+$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
if ( $postmeta ) {
?>
<?php foreach( $postmeta as $meta ) { ?>
@@ -82,9 +120,10 @@ if ( $postmeta ) {
<?php } ?>
<?php } ?>
<?php
-$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
+$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>
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
index c7c41d3..d7df5ad 100644
--- a/wp-admin/import/blogger.php
+++ b/wp-admin/import/blogger.php
@@ -525,7 +525,7 @@ class Blogger_Import {
$did_one = true;
}
$output.= "<p>$archivename $status</p>\n";
- }
+ }
if ( ! $did_one )
$this->set_next_step(7);
die( $this->refresher(1000) . $output );
diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php
index 780e45d..2cbf75f 100644
--- a/wp-admin/import/blogware.php
+++ b/wp-admin/import/blogware.php
@@ -20,7 +20,7 @@ class BW_Import {
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
-
+
function greet() {
echo '<div class="narrow">';
echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog. Pick a Blogware file to upload and click Import.').'</p>';
@@ -30,7 +30,7 @@ class BW_Import {
function import_posts() {
global $wpdb, $current_user;
-
+
set_magic_quotes_runtime(0);
$importdata = file($this->file); // Read the file into an array
$importdata = implode('', $importdata); // squish it
@@ -39,7 +39,7 @@ class BW_Import {
preg_match_all('|(<item[^>]+>(.*?)</item>)|is', $importdata, $posts);
$posts = $posts[1];
unset($importdata);
- echo '<ol>';
+ echo '<ol>';
foreach ($posts as $post) {
flush();
preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
@@ -102,7 +102,7 @@ class BW_Import {
preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
$comments = $comments[1];
-
+
if ( $comments ) {
$comment_post_ID = $post_id;
$num_comments = 0;
@@ -157,7 +157,7 @@ class BW_Import {
$this->file = $file['file'];
$this->import_posts();
wp_import_cleanup($file['id']);
-
+
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
@@ -170,7 +170,7 @@ class BW_Import {
$step = (int) $_GET['step'];
$this->header();
-
+
switch ($step) {
case 0 :
$this->greet();
@@ -179,12 +179,12 @@ class BW_Import {
$this->import();
break;
}
-
+
$this->footer();
}
function BW_Import() {
- // Nothing.
+ // Nothing.
}
}
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
index 026d871..02c030f 100644
--- a/wp-admin/import/dotclear.php
+++ b/wp-admin/import/dotclear.php
@@ -9,7 +9,7 @@
**/
if(!function_exists('get_catbynicename'))
{
- function get_catbynicename($category_nicename)
+ function get_catbynicename($category_nicename)
{
global $wpdb;
@@ -60,57 +60,58 @@ if(!function_exists('link_exists'))
//
// This cries out for a C-implementation to be included in PHP core
//
- function valid_1byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0x80) == 0x00;
- }
-
- function valid_2byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xE0) == 0xC0;
- }
-
- function valid_3byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xF0) == 0xE0;
- }
-
- function valid_4byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xF8) == 0xF0;
- }
-
- function valid_nextbyte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xC0) == 0x80;
- }
-
- function valid_utf8($string) {
- $len = strlen($string);
- $i = 0;
- while( $i < $len ) {
- $char = ord(substr($string, $i++, 1));
- if(valid_1byte($char)) { // continue
- continue;
- } else if(valid_2byte($char)) { // check 1 byte
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- } else if(valid_3byte($char)) { // check 2 bytes
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- } else if(valid_4byte($char)) { // check 3 bytes
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- } // goto next char
- }
- return true; // done
- }
+
+function valid_1byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0x80) == 0x00;
+}
+
+function valid_2byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xE0) == 0xC0;
+}
+
+function valid_3byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xF0) == 0xE0;
+}
+
+function valid_4byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xF8) == 0xF0;
+}
+
+function valid_nextbyte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xC0) == 0x80;
+}
+
+function valid_utf8($string) {
+ $len = strlen($string);
+ $i = 0;
+ while( $i < $len ) {
+ $char = ord(substr($string, $i++, 1));
+ if(valid_1byte($char)) { // continue
+ continue;
+ } else if(valid_2byte($char)) { // check 1 byte
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } else if(valid_3byte($char)) { // check 2 bytes
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } else if(valid_4byte($char)) { // check 3 bytes
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } // goto next char
+ }
+ return true; // done
+}
function csc ($s) {
if (valid_utf8 ($s)) {
@@ -151,7 +152,7 @@ class Dotclear_Import {
echo '</form></div>';
}
- function get_dc_cats()
+ function get_dc_cats()
{
global $wpdb;
// General Housekeeping
@@ -186,7 +187,7 @@ class Dotclear_Import {
// Get Posts
return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
- ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
+ ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
}
function get_dc_comments()
@@ -211,7 +212,7 @@ class Dotclear_Import {
return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
}
- function cat2wp($categories='')
+ function cat2wp($categories='')
{
// General Housekeeping
global $wpdb;
@@ -221,7 +222,7 @@ class Dotclear_Import {
if(is_array($categories))
{
echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
- foreach ($categories as $category)
+ foreach ($categories as $category)
{
$count++;
extract($category);
@@ -283,7 +284,7 @@ class Dotclear_Import {
'display_name' => $Realname)
);
}
- else
+ else
{
$ret_id = wp_insert_user(array(
'user_login' => $user_id,
@@ -384,7 +385,7 @@ class Dotclear_Import {
'comment_count' => $post_nb_comment + $post_nb_trackback)
);
}
- else
+ else
{
$ret_id = wp_insert_post(array(
'post_author' => $authorid,
@@ -460,7 +461,7 @@ class Dotclear_Import {
'comment_approved' => $comment_approved)
);
}
- else
+ else
{
// Insert comments
$ret_id = wp_insert_comment(array(
@@ -547,7 +548,7 @@ class Dotclear_Import {
return false;
}
- function import_categories()
+ function import_categories()
{
// Category Import
$cats = $this->get_dc_cats();
@@ -565,7 +566,7 @@ class Dotclear_Import {
function import_users()
{
// User Import
- $users = $this->get_dc_users();
+ $users = $this->get_dc_users();
$this->users2wp($users);
echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
@@ -655,7 +656,7 @@ class Dotclear_Import {
echo '</table>';
}
- function dispatch()
+ function dispatch()
{
if (empty ($_GET['step']))
@@ -664,7 +665,7 @@ class Dotclear_Import {
$step = (int) $_GET['step'];
$this->header();
- if ( $step > 0 )
+ if ( $step > 0 )
{
if($_POST['dbuser'])
{
@@ -689,25 +690,25 @@ class Dotclear_Import {
{
if(get_option('dchost'))
delete_option('dchost');
- add_option('dchost',$_POST['dbhost']);
+ add_option('dchost',$_POST['dbhost']);
}
if($_POST['dccharset'])
{
if(get_option('dccharset'))
delete_option('dccharset');
- add_option('dccharset',$_POST['dccharset']);
+ add_option('dccharset',$_POST['dccharset']);
}
if($_POST['dbprefix'])
{
if(get_option('dcdbprefix'))
delete_option('dcdbprefix');
- add_option('dcdbprefix',$_POST['dbprefix']);
+ add_option('dcdbprefix',$_POST['dbprefix']);
}
}
- switch ($step)
+ switch ($step)
{
default:
case 0 :
@@ -736,7 +737,7 @@ class Dotclear_Import {
$this->footer();
}
- function Dotclear_Import()
+ function Dotclear_Import()
{
// Nothing.
}
diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php
index 5494197..ea05ff2 100644
--- a/wp-admin/import/greymatter.php
+++ b/wp-admin/import/greymatter.php
@@ -66,10 +66,10 @@ class GM_Import {
$string = str_replace("|*|","<br />\n",$string);
return($string);
}
-
+
function import() {
global $wpdb;
-
+
$wpvarstoreset = array('gmpath', 'archivespath', 'lastentry');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
@@ -136,11 +136,11 @@ class GM_Import {
<li><?php _e('importing posts, comments, and karma...') ?><br /><ul><?php
chdir($archivespath);
-
+
for($i = 0; $i <= $lastentry; $i = $i + 1) {
-
+
$entryfile = "";
-
+
if ($i<10000000) {
$entryfile .= "0";
if ($i<1000000) {
@@ -194,7 +194,7 @@ class GM_Import {
$post_status = 'publish'; //in greymatter, there are no drafts
$comment_status = 'open';
$ping_status = 'closed';
-
+
if ($post_ID = post_exists($post_title, '', $post_date)) {
echo ' ';
_e('(already exists)');
@@ -303,7 +303,7 @@ class GM_Import {
}
function GM_Import() {
- // Nothing.
+ // Nothing.
}
}
diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php
index d484ba7..ffb869b 100644
--- a/wp-admin/import/mt.php
+++ b/wp-admin/import/mt.php
@@ -375,7 +375,7 @@ class MT_Import {
function import() {
$this->id = (int) $_GET['id'];
-
+
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$this->get_entries();
diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php
index e1a0339..435a588 100644
--- a/wp-admin/import/textpattern.php
+++ b/wp-admin/import/textpattern.php
@@ -4,7 +4,7 @@
**/
if(!function_exists('get_catbynicename'))
{
- function get_catbynicename($category_nicename)
+ function get_catbynicename($category_nicename)
{
global $wpdb;
@@ -70,13 +70,13 @@ class Textpattern_Import {
$prefix = get_option('tpre');
// Get Categories
- return $txpdb->get_results('SELECT
- id,
- name,
- title
- FROM '.$prefix.'txp_category
- WHERE type = "article"',
- ARRAY_A);
+ return $txpdb->get_results('SELECT
+ id,
+ name,
+ title
+ FROM '.$prefix.'txp_category
+ WHERE type = "article"',
+ ARRAY_A);
}
function get_txp_users()
@@ -90,12 +90,12 @@ class Textpattern_Import {
// Get Users
return $txpdb->get_results('SELECT
- user_id,
- name,
- RealName,
- email,
- privs
- FROM '.$prefix.'txp_users', ARRAY_A);
+ user_id,
+ name,
+ RealName,
+ email,
+ privs
+ FROM '.$prefix.'txp_users', ARRAY_A);
}
function get_txp_posts()
@@ -106,22 +106,22 @@ class Textpattern_Import {
$prefix = get_option('tpre');
// Get Posts
- return $txpdb->get_results('SELECT
- ID,
- Posted,
- AuthorID,
- LastMod,
- Title,
- Body,
- Excerpt,
- Category1,
- Category2,
- Status,
- Keywords,
- url_title,
- comments_count
- FROM '.$prefix.'textpattern
- ', ARRAY_A);
+ return $txpdb->get_results('SELECT
+ ID,
+ Posted,
+ AuthorID,
+ LastMod,
+ Title,
+ Body,
+ Excerpt,
+ Category1,
+ Category2,
+ Status,
+ Keywords,
+ url_title,
+ comments_count
+ FROM '.$prefix.'textpattern
+ ', ARRAY_A);
}
function get_txp_comments()
@@ -143,18 +143,18 @@ class Textpattern_Import {
set_magic_quotes_runtime(0);
$prefix = get_option('tpre');
- return $txpdb->get_results('SELECT
- id,
- date,
- category,
- url,
- linkname,
- description
- FROM '.$prefix.'txp_link',
- ARRAY_A);
+ return $txpdb->get_results('SELECT
+ id,
+ date,
+ category,
+ url,
+ linkname,
+ description
+ FROM '.$prefix.'txp_link',
+ ARRAY_A);
}
- function cat2wp($categories='')
+ function cat2wp($categories='')
{
// General Housekeeping
global $wpdb;
@@ -164,7 +164,7 @@ class Textpattern_Import {
if(is_array($categories))
{
echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
- foreach ($categories as $category)
+ foreach ($categories as $category)
{
$count++;
extract($category);
@@ -226,7 +226,7 @@ class Textpattern_Import {
'display_name' => $name)
);
}
- else
+ else
{
$ret_id = wp_insert_user(array(
'user_login' => $name,
@@ -302,35 +302,35 @@ class Textpattern_Import {
if($pinfo = post_exists($Title,$Body))
{
$ret_id = wp_insert_post(array(
- 'ID' => $pinfo,
- 'post_date' => $Posted,
- 'post_date_gmt' => $post_date_gmt,
- 'post_author' => $authorid,
- 'post_modified' => $LastMod,
- 'post_modified_gmt' => $post_modified_gmt,
- 'post_title' => $Title,
- 'post_content' => $Body,
- 'post_excerpt' => $Excerpt,
- 'post_status' => $post_status,
- 'post_name' => $url_title,
- 'comment_count' => $comments_count)
- );
+ 'ID' => $pinfo,
+ 'post_date' => $Posted,
+ 'post_date_gmt' => $post_date_gmt,
+ 'post_author' => $authorid,
+ 'post_modified' => $LastMod,
+ 'post_modified_gmt' => $post_modified_gmt,
+ 'post_title' => $Title,
+ 'post_content' => $Body,
+ 'post_excerpt' => $Excerpt,
+ 'post_status' => $post_status,
+ 'post_name' => $url_title,
+ 'comment_count' => $comments_count)
+ );
}
- else
+ else
{
$ret_id = wp_insert_post(array(
- 'post_date' => $Posted,
- 'post_date_gmt' => $post_date_gmt,
- 'post_author' => $authorid,
- 'post_modified' => $LastMod,
- 'post_modified_gmt' => $post_modified_gmt,
- 'post_title' => $Title,
- 'post_content' => $Body,
- 'post_excerpt' => $Excerpt,
- 'post_status' => $post_status,
- 'post_name' => $url_title,
- 'comment_count' => $comments_count)
- );
+ 'post_date' => $Posted,
+ 'post_date_gmt' => $post_date_gmt,
+ 'post_author' => $authorid,
+ 'post_modified' => $LastMod,
+ 'post_modified_gmt' => $post_modified_gmt,
+ 'post_title' => $Title,
+ 'post_content' => $Body,
+ 'post_excerpt' => $Excerpt,
+ 'post_status' => $post_status,
+ 'post_name' => $url_title,
+ 'comment_count' => $comments_count)
+ );
}
$txpposts2wpposts[$ID] = $ret_id;
@@ -379,29 +379,29 @@ class Textpattern_Import {
{
// Update comments
$ret_id = wp_update_comment(array(
- 'comment_ID' => $cinfo,
- 'comment_post_ID' => $comment_post_ID,
- 'comment_author' => $name,
- 'comment_author_email' => $email,
- 'comment_author_url' => $web,
- 'comment_date' => $posted,
- 'comment_content' => $message,
- 'comment_approved' => $comment_approved)
- );
+ 'comment_ID' => $cinfo,
+ 'comment_post_ID' => $comment_post_ID,
+ 'comment_author' => $name,
+ 'comment_author_email' => $email,
+ 'comment_author_url' => $web,
+ 'comment_date' => $posted,
+ 'comment_content' => $message,
+ 'comment_approved' => $comment_approved)
+ );
}
- else
+ else
{
// Insert comments
$ret_id = wp_insert_comment(array(
- 'comment_post_ID' => $comment_post_ID,
- 'comment_author' => $name,
- 'comment_author_email' => $email,
- 'comment_author_url' => $web,
- 'comment_author_IP' => $ip,
- 'comment_date' => $posted,
- 'comment_content' => $message,
- 'comment_approved' => $comment_approved)
- );
+ 'comment_post_ID' => $comment_post_ID,
+ 'comment_author' => $name,
+ 'comment_author_email' => $email,
+ 'comment_author_url' => $web,
+ 'comment_author_IP' => $ip,
+ 'comment_date' => $posted,
+ 'comment_content' => $message,
+ 'comment_approved' => $comment_approved)
+ );
}
$txpcm2wpcm[$comment_ID] = $ret_id;
}
@@ -450,7 +450,7 @@ class Textpattern_Import {
'link_updated' => $date)
);
}
- else
+ else
{
$ret_id = wp_insert_link(array(
'link_url' => $url,
@@ -472,7 +472,7 @@ class Textpattern_Import {
return false;
}
- function import_categories()
+ function import_categories()
{
// Category Import
$cats = $this->get_txp_cats();
@@ -490,7 +490,7 @@ class Textpattern_Import {
function import_users()
{
// User Import
- $users = $this->get_txp_users();
+ $users = $this->get_txp_users();
$this->users2wp($users);
echo '<form action="admin.php?import=textpattern&amp;step=3" method="post">';
@@ -578,7 +578,7 @@ class Textpattern_Import {
echo '</table>';
}
- function dispatch()
+ function dispatch()
{
if (empty ($_GET['step']))
@@ -587,7 +587,7 @@ class Textpattern_Import {
$step = (int) $_GET['step'];
$this->header();
- if ( $step > 0 )
+ if ( $step > 0 )
{
if($_POST['dbuser'])
{
@@ -612,19 +612,19 @@ class Textpattern_Import {
{
if(get_option('txphost'))
delete_option('txphost');
- add_option('txphost',$_POST['dbhost']);
+ add_option('txphost',$_POST['dbhost']);
}
if($_POST['dbprefix'])
{
if(get_option('tpre'))
delete_option('tpre');
- add_option('tpre',$_POST['dbprefix']);
+ add_option('tpre',$_POST['dbprefix']);
}
}
- switch ($step)
+ switch ($step)
{
default:
case 0 :
@@ -653,7 +653,7 @@ class Textpattern_Import {
$this->footer();
}
- function Textpattern_Import()
+ function Textpattern_Import()
{
// Nothing.
}
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index b850382..ac965b8 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -256,7 +256,7 @@ class WP_Import {
function import() {
$this->id = (int) $_GET['id'];
-
+
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$this->get_entries();
diff --git a/wp-admin/index-extra.php b/wp-admin/index-extra.php
new file mode 100644
index 0000000..782e0a7
--- /dev/null
+++ b/wp-admin/index-extra.php
@@ -0,0 +1,67 @@
+<?php
+require_once('admin.php');
+require_once (ABSPATH . WPINC . '/rss.php');
+
+switch ( $_GET['jax'] ) {
+
+case 'incominglinks' :
+$rss = @fetch_rss('http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('home')) .'&partner=wordpress');
+if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results
+?>
+<h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/search/<?php echo trailingslashit(get_option('home')); ?>?partner=wordpress"><?php _e('More &raquo;'); ?></a></cite></h3>
+<ul>
+<?php
+$rss->items = array_slice($rss->items, 0, 10);
+foreach ($rss->items as $item ) {
+?>
+ <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wptexturize(wp_specialchars($item['title'])); ?></a></li>
+<?php } ?>
+</ul>
+<?php
+}
+break;
+
+case 'devnews' :
+$rss = @fetch_rss('http://wordpress.org/development/feed/');
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+?>
+<h3><?php _e('WordPress Development Blog'); ?></h3>
+<?php
+$rss->items = array_slice($rss->items, 0, 3);
+foreach ($rss->items as $item ) {
+?>
+<h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4>
+<p><?php echo $item['description']; ?></p>
+<?php
+ }
+}
+?>
+
+<?php
+break;
+
+case 'planetnews' :
+$rss = @fetch_rss('http://planet.wordpress.org/feed/');
+if ( isset($rss->items) && 0 != count($rss->items) ) {
+?>
+<h3><?php _e('Other WordPress News'); ?></h3>
+<ul>
+<?php
+$rss->items = array_slice($rss->items, 0, 20);
+foreach ($rss->items as $item ) {
+$title = wp_specialchars($item['title']);
+$author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] );
+$post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] );
+?>
+<li><a href='<?php echo wp_filter_kses($item['link']); ?>'><span class="post"><?php echo $post; ?></span><span class="hidden"> - </span><cite><?php echo $author; ?></cite></a></li>
+<?php
+ }
+?>
+</ul>
+<p class="readmore"><a href="http://planet.wordpress.org/"><?php _e('Read more'); ?> &raquo;</a></p>
+<?php
+}
+break;
+}
+
+?> \ No newline at end of file
diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php
index 86138db..b441c34 100644
--- a/wp-admin/install-helper.php
+++ b/wp-admin/install-helper.php
@@ -9,21 +9,21 @@ $debug = 0;
** false on error
*/
function maybe_create_table($table_name, $create_ddl) {
- global $wpdb;
- foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
- if ($table == $table_name) {
- return true;
- }
- }
- //didn't find it try to create it.
- $q = $wpdb->query($create_ddl);
- // we cannot directly tell that whether this succeeded!
- foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
- if ($table == $table_name) {
- return true;
- }
- }
- return false;
+ global $wpdb;
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -33,22 +33,22 @@ function maybe_create_table($table_name, $create_ddl) {
** false on error
*/
function maybe_add_column($table_name, $column_name, $create_ddl) {
- global $wpdb, $debug;
- foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
- if ($debug) echo("checking $column == $column_name<br />");
- if ($column == $column_name) {
- return true;
- }
- }
- //didn't find it try to create it.
- $q = $wpdb->query($create_ddl);
- // we cannot directly tell that whether this succeeded!
- foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
- if ($column == $column_name) {
- return true;
- }
- }
- return false;
+ global $wpdb, $debug;
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($debug) echo("checking $column == $column_name<br />");
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ return false;
}
@@ -59,21 +59,21 @@ function maybe_add_column($table_name, $column_name, $create_ddl) {
** false on error
*/
function maybe_drop_column($table_name, $column_name, $drop_ddl) {
- global $wpdb;
- foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
- if ($column == $column_name) {
- //found it try to drop it.
- $q = $wpdb->query($drop_ddl);
- // we cannot directly tell that whether this succeeded!
- foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
- if ($column == $column_name) {
- return false;
- }
- }
- }
- }
- // else didn't find it
- return true;
+ global $wpdb;
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($column == $column_name) {
+ //found it try to drop it.
+ $q = $wpdb->query($drop_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+ if ($column == $column_name) {
+ return false;
+ }
+ }
+ }
+ }
+ // else didn't find it
+ return true;
}
@@ -92,45 +92,45 @@ function maybe_drop_column($table_name, $column_name, $drop_ddl) {
** Extra
*/
function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) {
- global $wpdb, $debug;
- $diffs = 0;
- $results = $wpdb->get_results("DESC $table_name");
-
- foreach ($results as $row ) {
- if ($debug > 1) print_r($row);
- if ($row->Field == $col_name) {
- // got our column, check the params
- if ($debug) echo ("checking $row->Type against $col_type\n");
- if (($col_type != null) && ($row->Type != $col_type)) {
- ++$diffs;
- }
- if (($is_null != null) && ($row->Null != $is_null)) {
- ++$diffs;
- }
- if (($key != null) && ($row->Key != $key)) {
- ++$diffs;
- }
- if (($default != null) && ($row->Default != $default)) {
- ++$diffs;
- }
- if (($extra != null) && ($row->Extra != $extra)) {
- ++$diffs;
- }
- if ($diffs > 0) {
- if ($debug) echo ("diffs = $diffs returning false\n");
- return false;
- }
- return true;
- } // end if found our column
- }
- return false;
+ global $wpdb, $debug;
+ $diffs = 0;
+ $results = $wpdb->get_results("DESC $table_name");
+
+ foreach ($results as $row ) {
+ if ($debug > 1) print_r($row);
+ if ($row->Field == $col_name) {
+ // got our column, check the params
+ if ($debug) echo ("checking $row->Type against $col_type\n");
+ if (($col_type != null) && ($row->Type != $col_type)) {
+ ++$diffs;
+ }
+ if (($is_null != null) && ($row->Null != $is_null)) {
+ ++$diffs;
+ }
+ if (($key != null) && ($row->Key != $key)) {
+ ++$diffs;
+ }
+ if (($default != null) && ($row->Default != $default)) {
+ ++$diffs;
+ }
+ if (($extra != null) && ($row->Extra != $extra)) {
+ ++$diffs;
+ }
+ if ($diffs > 0) {
+ if ($debug) echo ("diffs = $diffs returning false\n");
+ return false;
+ }
+ return true;
+ } // end if found our column
+ }
+ return false;
}
-
+
/*
echo "<p>testing</p>";
echo "<pre>";
-//check_column('wp_links', 'link_description', 'mediumtext');
+//check_column('wp_links', 'link_description', 'mediumtext');
//if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
// echo "ok\n";
$error_count = 0;
@@ -138,15 +138,15 @@ $tablename = $wpdb->links;
// check the column
if (!check_column($wpdb->links, 'link_description', 'varchar(255)'))
{
- $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
- $q = $wpdb->query($ddl);
+ $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
+ $q = $wpdb->query($ddl);
}
if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
- $res .= $tablename . ' - ok <br />';
+ $res .= $tablename . ' - ok <br />';
} else {
- $res .= 'There was a problem with ' . $tablename . '<br />';
- ++$error_count;
+ $res .= 'There was a problem with ' . $tablename . '<br />';
+ ++$error_count;
}
echo "</pre>";
*/
-?> \ No newline at end of file
+?>
diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php
index 22dcc64..2f66e44 100644
--- a/wp-admin/link-add.php
+++ b/wp-admin/link-add.php
@@ -1,15 +1,15 @@
<?php
require_once('admin.php');
-$title = __('Add Bookmark');
+$title = __('Add Link');
$this_file = 'link-manager.php';
$parent_file = 'link-manager.php';
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
- 'description', 'visible', 'target', 'category', 'link_id',
- 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
- 'notes', 'linkcheck[]'));
+ 'description', 'visible', 'target', 'category', 'link_id',
+ 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
+ 'notes', 'linkcheck[]'));
wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
if ( current_user_can( 'manage_categories' ) )
diff --git a/wp-admin/link-import.php b/wp-admin/link-import.php
index 98bdc87..9f1e0c0 100644
--- a/wp-admin/link-import.php
+++ b/wp-admin/link-import.php
@@ -16,7 +16,7 @@ switch ($step) {
{
include_once('admin-header.php');
if ( !current_user_can('manage_links') )
- die (__("Cheatin&#8217; uh?"));
+ wp_die(__('Cheatin&#8217; uh?'));
$opmltype = 'blogrolling'; // default.
?>
@@ -26,7 +26,7 @@ switch ($step) {
<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
<?php wp_nonce_field('import-bookmarks') ?>
-<p><?php _e('If a program or website you use allows you to export your bookmarks or subscriptions as OPML you may import them here.'); ?>
+<p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?>
<div style="width: 70%; margin: auto; height: 8em;">
<input type="hidden" name="step" value="1" />
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
@@ -43,7 +43,7 @@ switch ($step) {
</div>
-<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these bookmarks in.') ?><br />
+<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these links in.') ?><br />
<?php _e('Category:') ?> <select name="cat_id">
<?php
$categories = get_categories('hide_empty=0');
@@ -68,7 +68,7 @@ foreach ($categories as $category) {
include_once('admin-header.php');
if ( !current_user_can('manage_links') )
- die (__("Cheatin' uh ?"));
+ wp_die(__('Cheatin&#8217; uh?'));
?>
<div class="wrap">
@@ -111,7 +111,7 @@ foreach ($categories as $category) {
echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
}
?>
- <p><?php printf(__('Inserted %1$d bookmarks into category %2$s. All done! Go <a href="%3$s">manage those bookmarks</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
+ <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
<?php
} // end if got url
else
diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php
index a4a2639..abb1d37 100644
--- a/wp-admin/link-manager.php
+++ b/wp-admin/link-manager.php
@@ -6,8 +6,6 @@
require_once ('admin.php');
-$title = __('Manage Bookmarks');
-$this_file = $parent_file = 'link-manager.php';
wp_enqueue_script( 'listman' );
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
@@ -18,11 +16,12 @@ if (empty ($cat_id))
if (empty ($order_by))
$order_by = 'order_name';
-$title = __('Manage Bookmarks');
+$title = __('Manage Blogroll');
+$this_file = $parent_file = 'link-manager.php';
include_once ("./admin-header.php");
if (!current_user_can('manage_links'))
- wp_die(__("You do not have sufficient permissions to edit the bookmarks for this blog."));
+ wp_die(__("You do not have sufficient permissions to edit the links for this blog."));
switch ($order_by) {
case 'order_id' :
@@ -66,7 +65,7 @@ function checkAll(form)
if ( isset($_GET['deleted']) ) {
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
$deleted = (int) $_GET['deleted'];
- printf(__('%s bookmarks deleted.'), $deleted);
+ printf(__('%s links deleted.'), $deleted);
echo '</p></div>';
}
?>
@@ -85,7 +84,7 @@ foreach ((array) $categories as $cat)
$select_cat .= "</select>\n";
$select_order = "<select name=\"order_by\">\n";
-$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Bookmark ID') . "</option>\n";
+$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Link ID') . "</option>\n";
$select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Name') . "</option>\n";
$select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Address') . "</option>\n";
$select_order .= "</select>\n";
@@ -143,8 +142,8 @@ if ($links)
echo $link->link_description . "</td>";
echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>";
?>
- <td>
- <?php
+ <td>
+ <?php
$cat_names = array();
foreach ($link->link_category as $category) {
@@ -157,12 +156,12 @@ if ($links)
echo implode(', ', $cat_names);
?>
</td>
- <td><?php echo $link->link_rel; ?></td>
- <td align='center'><?php echo $visible; ?></td>
+ <td><?php echo $link->link_rel; ?></td>
+ <td align='center'><?php echo $visible; ?></td>
<?php
echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=edit" class="edit">'.__('Edit').'</a></td>';
- echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&amp;action=delete', 'delete-bookmark_' . $link->link_id ) . '"'." onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($link->link_name), js_escape($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
+ echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&amp;action=delete', 'delete-bookmark_' . $link->link_id ) . '"'." onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; link to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($link->link_name), js_escape($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
echo "\n </tr>\n";
}
@@ -172,7 +171,7 @@ if ($links)
<div id="ajax-response"></div>
-<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Bookmarks') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these bookmarks permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p>
+<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Links') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these links permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p>
</form>
</div>
diff --git a/wp-admin/link-parse-opml.php b/wp-admin/link-parse-opml.php
index 196f3cb..0e5edf0 100644
--- a/wp-admin/link-parse-opml.php
+++ b/wp-admin/link-parse-opml.php
@@ -4,12 +4,12 @@ require_once('../wp-config.php');
// columns we wish to find are: link_url, link_name, link_target, link_description
// we need to map XML attribute names to our columns
$opml_map = array('URL' => 'link_url',
- 'HTMLURL' => 'link_url',
- 'TEXT' => 'link_name',
- 'TITLE' => 'link_name',
- 'TARGET' => 'link_target',
- 'DESCRIPTION' => 'link_description',
- 'XMLURL' => 'link_rss'
+ 'HTMLURL' => 'link_url',
+ 'TEXT' => 'link_name',
+ 'TITLE' => 'link_name',
+ 'TARGET' => 'link_target',
+ 'DESCRIPTION' => 'link_description',
+ 'XMLURL' => 'link_rss'
);
$map = $opml_map;
@@ -20,24 +20,24 @@ $map = $opml_map;
**/
function startElement($parser, $tagName, $attrs) {
global $updated_timestamp, $all_links, $map;
- global $names, $urls, $targets, $descriptions, $feeds;
+ global $names, $urls, $targets, $descriptions, $feeds;
if ($tagName == 'OUTLINE') {
- foreach (array_keys($map) as $key) {
- if (isset($attrs[$key])) {
- $$map[$key] = $attrs[$key];
- }
- }
+ foreach (array_keys($map) as $key) {
+ if (isset($attrs[$key])) {
+ $$map[$key] = $attrs[$key];
+ }
+ }
- //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
+ //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
- // save the data away.
- $names[] = $link_name;
- $urls[] = $link_url;
- $targets[] = $link_target;
+ // save the data away.
+ $names[] = $link_name;
+ $urls[] = $link_url;
+ $targets[] = $link_target;
$feeds[] = $link_rss;
- $descriptions[] = $link_description;
- } // end if outline
+ $descriptions[] = $link_description;
+ } // end if outline
}
/**
@@ -55,9 +55,9 @@ $xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!xml_parse($xml_parser, $opml, true)) {
- echo(sprintf(__('XML error: %1$s at line %2$s'),
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
+ echo(sprintf(__('XML error: %1$s at line %2$s'),
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
}
// Free up memory used by the XML parser
diff --git a/wp-admin/link.php b/wp-admin/link.php
index 0590f16..425e912 100644
--- a/wp-admin/link.php
+++ b/wp-admin/link.php
@@ -29,12 +29,13 @@ switch ($action) {
$deleted = 0;
foreach ($linkcheck as $link_id) {
$link_id = (int) $link_id;
-
+
if ( wp_delete_link($link_id) )
$deleted++;
}
wp_redirect("$this_file?deleted=$deleted");
+ exit;
break;
case 'move' :
@@ -54,6 +55,7 @@ switch ($action) {
//$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
wp_redirect($this_file);
+ exit;
break;
case 'add' :
@@ -62,6 +64,7 @@ switch ($action) {
add_link();
wp_redirect(wp_get_referer().'?added=true');
+ exit;
break;
case 'save' :
@@ -84,6 +87,7 @@ switch ($action) {
wp_delete_link($link_id);
wp_redirect($this_file);
+ exit;
break;
case 'edit' :
@@ -92,10 +96,10 @@ switch ($action) {
wp_enqueue_script( 'ajaxcat' );
$parent_file = 'link-manager.php';
$submenu_file = 'link-manager.php';
- $title = __('Edit Bookmark');
+ $title = __('Edit Link');
include_once ('admin-header.php');
if (!current_user_can('manage_links'))
- wp_die(__('You do not have sufficient permissions to edit the bookmarks for this blog.'));
+ wp_die(__('You do not have sufficient permissions to edit the links for this blog.'));
$link_id = (int) $_GET['link_id'];
diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php
index d113276..046590e 100644
--- a/wp-admin/menu-header.php
+++ b/wp-admin/menu-header.php
@@ -10,8 +10,15 @@ foreach ($menu as $item) {
// 0 = name, 1 = capability, 2 = file
if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
-
- if ( !empty($submenu[$item[2]]) || current_user_can($item[1]) ) {
+
+ if ( !empty($submenu[$item[2]]) ) {
+ $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
+ $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
+ if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
+ echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
+ else
+ echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
+ } else if ( current_user_can($item[1]) ) {
if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") )
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else
@@ -27,8 +34,8 @@ foreach ($menu as $item) {
if ( isset($submenu["$parent_file"]) ) :
?>
<ul id="submenu">
-<?php
-foreach ($submenu["$parent_file"] as $item) :
+<?php
+foreach ($submenu["$parent_file"] as $item) :
if ( !current_user_can($item[1]) )
continue;
@@ -58,7 +65,7 @@ else :
<div id="minisub"></div>
<?php
-endif;
+endif;
do_action('admin_notices');
diff --git a/wp-admin/menu.php b/wp-admin/menu.php
index a506d1b..bb82c1f 100644
--- a/wp-admin/menu.php
+++ b/wp-admin/menu.php
@@ -17,7 +17,8 @@ else
$menu_perms = get_site_option( "menu_items" );
if( is_array( $menu_perms ) == false )
$menu_perms = array();
-
+
+$menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
$menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php');
$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
if( $menu_perms[ 'plugins' ] == 1 )
@@ -32,13 +33,15 @@ $menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
$submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php');
$submenu['post-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php');
+$submenu['edit-comments.php'][5] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
+$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
+$submenu['edit-comments.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "<span id='awaitmod'>$awaiting_mod</span>"), 'edit_posts', 'moderation.php');
+
+
$submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
$submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
$submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php');
$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php');
-$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
-$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
-$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "<span id='awaitmod'>$awaiting_mod</span>"), 'edit_posts', 'moderation.php');
//$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php');
$submenu['edit.php'][35] = array(__('Import'), 'import', 'import.php');
$submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php');
diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php
index b9e3f06..e9fc505 100644
--- a/wp-admin/moderation.php
+++ b/wp-admin/moderation.php
@@ -2,7 +2,7 @@
require_once('admin.php');
$title = __('Moderate comments');
-$parent_file = 'edit.php';
+$parent_file = 'edit-comments.php';
wp_enqueue_script( 'admin-comments' );
wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'));
@@ -31,7 +31,7 @@ case 'update':
foreach($comment as $key => $value) {
if ($feelinglucky && 'later' == $value)
$value = 'delete';
- switch($value) {
+ switch($value) {
case 'later':
// do nothing with that comment
// wp_set_comment_status($key, "hold");
@@ -41,10 +41,10 @@ case 'update':
wp_set_comment_status($key, 'delete');
++$item_deleted;
break;
- case 'spam':
- wp_set_comment_status($key, 'spam');
- ++$item_spam;
- break;
+ case 'spam':
+ wp_set_comment_status($key, 'spam');
+ ++$item_spam;
+ break;
case 'approve':
wp_set_comment_status($key, 'approve');
if ( get_option('comments_notify') == true ) {
@@ -52,7 +52,7 @@ case 'update':
}
++$item_approved;
break;
- }
+ }
}
$file = basename(__FILE__);
@@ -85,13 +85,13 @@ if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored
echo sprintf(__("%s comments deleted"), $deleted) . " <br/>\n";
}
}
- if ($spam) {
- if ('1' == $spam) {
+ if ($spam) {
+ if ('1' == $spam) {
echo __("1 comment marked as spam") . " <br/>\n";
- } else {
- echo sprintf(__("%s comments marked as spam"), $spam) . " <br/>\n";
- }
- }
+ } else {
+ echo sprintf(__("%s comments marked as spam"), $spam) . " <br/>\n";
+ }
+ }
if ($ignored) {
if ('1' == $ignored) {
echo __("1 comment unchanged") . " <br/>\n";
@@ -151,13 +151,13 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
</li>
<?php
- }
+ }
?>
- </ol>
+ </ol>
<div id="ajax-response"></div>
- <p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments &raquo;') ?>" /></p>
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments &raquo;') ?>" /></p>
<script type="text/javascript">
// <![CDATA[
function markAllForDelete() {
@@ -197,10 +197,10 @@ document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark
<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>
+</form>
<?php
} else {
- // nothing to approve
+ // nothing to approve
echo '<p>'.__("Currently there are no comments for you to moderate.") . "</p>\n";
}
?>
diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php
index dba00f2..cb68832 100644
--- a/wp-admin/options-misc.php
+++ b/wp-admin/options-misc.php
@@ -8,9 +8,9 @@ $parent_file = 'options-general.php';
include('admin-header.php');
?>
-
-<div class="wrap">
-<h2><?php _e('Miscellaneous Options') ?></h2>
+
+<div class="wrap">
+<h2><?php _e('Miscellaneous Options') ?></h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
@@ -44,10 +44,10 @@ include('admin-header.php');
<p class="submit">
<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path" />
+<input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path" />
<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
</p>
-</form>
+</form>
</div>
<?php include('./admin-footer.php'); ?>
diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php
index a5d17f1..eb7ac66 100644
--- a/wp-admin/options-permalink.php
+++ b/wp-admin/options-permalink.php
@@ -144,7 +144,7 @@ $structures = array(
<?php if ( !in_array($permalink_structure, $structures) ) { ?>
checked="checked"
<?php } ?>
- />
+ />
<?php _e('Custom, specify below'); ?>
</label>
<br />
diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php
index fc73637..c603a88 100644
--- a/wp-admin/options-reading.php
+++ b/wp-admin/options-reading.php
@@ -63,10 +63,7 @@ if ( 'page' == get_option('show_on_front') ) {
<tr valign="top">
<th width="33%" scope="row"><?php _e('Show at most:') ?></th>
<td>
-<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" />
-<select name="what_to_show" id="what_to_show" >
-<option value="days" <?php selected('days', get_option('what_to_show')); ?>><?php _e('days') ?></option>
-<option value="posts" <?php selected('posts', get_option('what_to_show')); ?>><?php _e('posts') ?></option>
+<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" /> <?php _e('posts') ?>
</select>
</td>
</tr>
@@ -99,7 +96,8 @@ if ( 'page' == get_option('show_on_front') ) {
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="posts_per_page,what_to_show,posts_per_rss,rss_use_excerpt,blog_charset,show_on_front,page_on_front,page_for_posts" />
+<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
+<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,show_on_front,page_on_front,page_for_posts" />
<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
</p>
</form>
diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php
index acb6dff..59e1c49 100644
--- a/wp-admin/options-writing.php
+++ b/wp-admin/options-writing.php
@@ -57,11 +57,11 @@ endforeach;
<p class="submit">
-<input type="hidden" name="action" value="update" />
+<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,default_category,default_email_category,use_balanceTags,default_link_category" />
-<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
+<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
</p>
-</form>
-</div>
+</form>
+</div>
<?php include('./admin-footer.php') ?>
diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php
index 42fe9d4..3020b48 100644
--- a/wp-admin/plugin-editor.php
+++ b/wp-admin/plugin-editor.php
@@ -62,8 +62,8 @@ default:
<?php if (isset($_GET['a'])) : ?>
<div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
<?php endif; ?>
- <div class="wrap">
- <?php
+ <div class="wrap">
+ <?php
if (is_writeable($real_file)) {
echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
} else {
@@ -76,39 +76,39 @@ default:
<?php
if ($plugin_files) :
?>
- <ul>
-<?php foreach($plugin_files as $plugin_file) : ?>
+ <ul>
+ <?php foreach($plugin_files as $plugin_file) : ?>
<li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
-<?php endforeach; ?>
- </ul>
+ <?php endforeach; ?>
+ </ul>
<?php endif; ?>
</div>
- <?php if (!$error) { ?>
- <form name="template" id="template" action="plugin-editor.php" method="post">
- <?php wp_nonce_field('edit-plugin_' . $file) ?>
- <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
- <input type="hidden" name="action" value="update" />
- <input type="hidden" name="file" value="<?php echo $file ?>" />
+<?php if (!$error) { ?>
+ <form name="template" id="template" action="plugin-editor.php" method="post">
+ <?php wp_nonce_field('edit-plugin_' . $file) ?>
+ <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
</div>
<?php if ( is_writeable($real_file) ) : ?>
- <p class="submit">
-<?php
- echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
-?>
-</p>
+ <p class="submit">
+ <?php
+ echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
+ ?>
+ </p>
<?php else : ?>
-<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
+ <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
<?php endif; ?>
- </form>
- <?php
+ </form>
+<?php
} else {
echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
}
- ?>
+?>
<div class="clear"> &nbsp; </div>
-</div>
+</div>
<?php
break;
}
-include("admin-footer.php") ?>
+include("admin-footer.php") ?>
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php
index 2acf689..f224937 100644
--- a/wp-admin/plugins.php
+++ b/wp-admin/plugins.php
@@ -12,12 +12,17 @@ if ( isset($_GET['action']) ) {
if ('activate' == $_GET['action']) {
check_admin_referer('activate-plugin_' . $_GET['plugin']);
$current = get_option('active_plugins');
- if (!in_array($_GET['plugin'], $current)) {
- $current[] = trim( $_GET['plugin'] );
+ $plugin = trim($_GET['plugin']);
+ if ( validate_file($plugin) )
+ wp_die(__('Invalid plugin.'));
+ if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
+ wp_die(__('Plugin file does not exist.'));
+ if (!in_array($plugin, $current)) {
+ $current[] = $plugin;
sort($current);
update_option('active_plugins', $current);
- include(ABSPATH . PLUGINDIR . '/' . trim( $_GET['plugin'] ));
- do_action('activate_' . trim( $_GET['plugin'] ));
+ include(ABSPATH . PLUGINDIR . '/' . $plugin);
+ do_action('activate_' . $plugin);
}
wp_redirect('plugins.php?activate=true');
} else if ('deactivate' == $_GET['action']) {
@@ -110,7 +115,7 @@ if (empty($plugins)) {
$plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ;
if ( $style != '' )
$style = 'class="' . $style . '"';
- if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
+ if ( is_writable(ABSPATH . 'wp-content/plugins/' . $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 = '';
diff --git a/wp-admin/post.php b/wp-admin/post.php
index 9c93695..31d16bd 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -15,7 +15,7 @@ case 'post':
$parent_file = 'post-new.php';
$submenu_file = 'post-new.php';
check_admin_referer('add-post');
-
+
$post_ID = 'post' == $action ? write_post() : edit_post();
// Redirect.
@@ -89,7 +89,7 @@ case 'editattachment':
case 'editpost':
$post_ID = (int) $_POST['post_ID'];
check_admin_referer('update-post_' . $post_ID);
-
+
$post_ID = edit_post();
if ( 'post' == $_POST['originalaction'] ) {
diff --git a/wp-admin/profile.php b/wp-admin/profile.php
index f1c38b4..6c96230 100644
--- a/wp-admin/profile.php
+++ b/wp-admin/profile.php
@@ -1,4 +1,4 @@
-<?php
+<?php
require_once('admin.php');
$title = __('Profile');
@@ -30,13 +30,14 @@ $bookmarklet_height= 440;
<h3><?php _e('Personal Options'); ?></h3>
+<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> />
<?php _e('Use the visual editor when writing') ?></label></p>
+<?php endif; ?>
<?php do_action('profile_personal_options'); ?>
<p class="submit"><input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" /></p>
-<div style="clear: both"></div>
<fieldset>
<legend><?php _e('Name'); ?></legend>
@@ -120,13 +121,13 @@ if ( $show_password_fields ) :
<br clear="all" />
- <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
- <?php
- if(count($profileuser->caps) > count($profileuser->roles)):
- ?>
- <tr>
- <th scope="row"><?php _e('Additional Capabilities:') ?></th>
- <td><?php
+ <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
+ <?php
+ if(count($profileuser->caps) > count($profileuser->roles)):
+ ?>
+ <tr>
+ <th scope="row"><?php _e('Additional Capabilities:') ?></th>
+ <td><?php
$output = '';
foreach($profileuser->caps as $cap => $value) {
if(!$wp_roles->is_role($cap)) {
diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php
index d25c58b..17846d6 100644
--- a/wp-admin/setup-config.php
+++ b/wp-admin/setup-config.php
@@ -3,7 +3,7 @@ die();
define('WP_INSTALLING', true);
if (!file_exists('../wp-config-sample.php'))
- die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
+ die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
$configFile = file('../wp-config-sample.php');
@@ -83,103 +83,103 @@ if (file_exists('../wp-config.php'))
switch($step) {
case 0:
-?>
-
-<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
-<ol>
- <li>Database name</li>
- <li>Database username</li>
- <li>Database password</li>
- <li>Database host</li>
- <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
-</ol>
+?>
+
+<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
+<ol>
+ <li>Database name</li>
+ <li>Database username</li>
+ <li>Database password</li>
+ <li>Database host</li>
+ <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
+</ol>
<p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
<p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready, <a href="setup-config.php?step=1">let&#8217;s go</a>! </p>
<?php
break;
case 1:
- ?>
-</p>
+ ?>
+</p>
<form method="post" action="setup-config.php?step=2">
- <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
- <table>
- <tr>
- <th scope="row">Database Name</th>
- <td><input name="dbname" type="text" size="25" value="wordpress" /></td>
- <td>The name of the database you want to run WP in. </td>
- </tr>
- <tr>
- <th scope="row">User Name</th>
- <td><input name="uname" type="text" size="25" value="username" /></td>
- <td>Your MySQL username</td>
- </tr>
- <tr>
- <th scope="row">Password</th>
- <td><input name="pwd" type="text" size="25" value="password" /></td>
- <td>...and MySQL password.</td>
- </tr>
- <tr>
- <th scope="row">Database Host</th>
- <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
- <td>99% chance you won't need to change this value.</td>
- </tr>
- <tr>
- <th scope="row">Table Prefix</th>
- <td><input name="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
- <td>If you want to run multiple WordPress installations in a single database, change this.</td>
- </tr>
- </table>
- <h2 class="step">
- <input name="submit" type="submit" value="Submit" />
- </h2>
-</form>
+ <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
+ <table>
+ <tr>
+ <th scope="row">Database Name</th>
+ <td><input name="dbname" type="text" size="25" value="wordpress" /></td>
+ <td>The name of the database you want to run WP in. </td>
+ </tr>
+ <tr>
+ <th scope="row">User Name</th>
+ <td><input name="uname" type="text" size="25" value="username" /></td>
+ <td>Your MySQL username</td>
+ </tr>
+ <tr>
+ <th scope="row">Password</th>
+ <td><input name="pwd" type="text" size="25" value="password" /></td>
+ <td>...and MySQL password.</td>
+ </tr>
+ <tr>
+ <th scope="row">Database Host</th>
+ <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
+ <td>99% chance you won't need to change this value.</td>
+ </tr>
+ <tr>
+ <th scope="row">Table Prefix</th>
+ <td><input name="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
+ <td>If you want to run multiple WordPress installations in a single database, change this.</td>
+ </tr>
+ </table>
+ <h2 class="step">
+ <input name="submit" type="submit" value="Submit" />
+ </h2>
+</form>
<?php
break;
case 2:
$dbname = trim($_POST['dbname']);
- $uname = trim($_POST['uname']);
- $passwrd = trim($_POST['pwd']);
- $dbhost = trim($_POST['dbhost']);
+ $uname = trim($_POST['uname']);
+ $passwrd = trim($_POST['pwd']);
+ $dbhost = trim($_POST['dbhost']);
$prefix = trim($_POST['prefix']);
if (empty($prefix)) $prefix = 'wp_';
- // Test the db connection.
- define('DB_NAME', $dbname);
- define('DB_USER', $uname);
- define('DB_PASSWORD', $passwrd);
- define('DB_HOST', $dbhost);
+ // Test the db connection.
+ define('DB_NAME', $dbname);
+ define('DB_USER', $uname);
+ define('DB_PASSWORD', $passwrd);
+ define('DB_HOST', $dbhost);
- // We'll fail here if the values are no good.
- require_once('../wp-includes/wp-db.php');
+ // We'll fail here if the values are no good.
+ require_once('../wp-includes/wp-db.php');
$handle = fopen('../wp-config.php', 'w');
- foreach ($configFile as $line_num => $line) {
- switch (substr($line,0,16)) {
- case "define('DB_NAME'":
- fwrite($handle, str_replace("wordpress", $dbname, $line));
- break;
- case "define('DB_USER'":
- fwrite($handle, str_replace("'username'", "'$uname'", $line));
- break;
- case "define('DB_PASSW":
- fwrite($handle, str_replace("'password'", "'$passwrd'", $line));
- break;
- case "define('DB_HOST'":
- fwrite($handle, str_replace("localhost", $dbhost, $line));
- break;
+ foreach ($configFile as $line_num => $line) {
+ switch (substr($line,0,16)) {
+ case "define('DB_NAME'":
+ fwrite($handle, str_replace("wordpress", $dbname, $line));
+ break;
+ case "define('DB_USER'":
+ fwrite($handle, str_replace("'username'", "'$uname'", $line));
+ break;
+ case "define('DB_PASSW":
+ fwrite($handle, str_replace("'password'", "'$passwrd'", $line));
+ break;
+ case "define('DB_HOST'":
+ fwrite($handle, str_replace("localhost", $dbhost, $line));
+ break;
case '$table_prefix =':
fwrite($handle, str_replace('wp_', $prefix, $line));
break;
- default:
- fwrite($handle, $line);
- }
- }
- fclose($handle);
+ default:
+ fwrite($handle, $line);
+ }
+ }
+ fclose($handle);
chmod('../wp-config.php', 0666);
-?>
-<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to <a href="install.php">run the install!</a></p>
+?>
+<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to <a href="install.php">run the install!</a></p>
<?php
break;
}
diff --git a/wp-admin/sidebar.php b/wp-admin/sidebar.php
index 256c1a2..a2ea264 100644
--- a/wp-admin/sidebar.php
+++ b/wp-admin/sidebar.php
@@ -34,15 +34,15 @@ form {
padding: 3px;
}
.sidebar-categories {
- display: block;
- height: 6.6em;
- overflow: auto;
- background-color: #f4f4f4;
+ display: block;
+ height: 6.6em;
+ overflow: auto;
+ background-color: #f4f4f4;
}
.sidebar-categories label {
font-size: 10px;
- display: block;
- width: 90%;
+ display: block;
+ width: 90%;
}
</style>
</head>
@@ -65,9 +65,9 @@ Post:
<textarea rows="8" cols="12" style="width: 100%" name="content" tabindex="2"></textarea>
</p>
<p>
- <input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="Save as Draft" />
+ <input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="Save as Draft" />
<?php if ( current_user_can('publish_posts') ) : ?>
- <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="Publish" />
+ <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="Publish" />
<?php endif; ?>
</p>
</div>
diff --git a/wp-admin/templates.php b/wp-admin/templates.php
index 3608371..b38465b 100644
--- a/wp-admin/templates.php
+++ b/wp-admin/templates.php
@@ -83,7 +83,7 @@ default:
<div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
<?php endif; ?>
<?php endif; ?>
- <div class="wrap">
+ <div class="wrap">
<?php
if (is_writeable($real_file)) {
echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>';
@@ -92,14 +92,14 @@ if (is_writeable($real_file)) {
}
?>
<div id="templateside">
-<?php
-if ( $recents ) :
+<?php
+if ( $recents ) :
?>
<h3><?php _e('Recent'); ?></h3>
<?php
echo '<ol>';
foreach ($recents as $recent) :
- echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>";
+ echo "<li><a href='templates.php?file=" . wp_specialchars($recent, true) . "'>" . get_file_description(basename($recent)) . "</a></li>";
endforeach;
echo '</ol>';
endif;
@@ -111,21 +111,21 @@ endif;
if (file_exists(ABSPATH . $old_file))
$common_files[] = $old_file;
} ?>
- <ul>
- <?php foreach ($common_files as $common_file) : ?>
- <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
- <?php endforeach; ?>
- </ul>
+<ul>
+ <?php foreach ($common_files as $common_file) : ?>
+ <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
+ <?php endforeach; ?>
+</ul>
</div>
<?php if (!$error) { ?>
- <form name="template" id="template" action="templates.php" method="post">
- <?php wp_nonce_field('edit-file_' . $file) ?>
- <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea>
- <input type="hidden" name="action" value="update" />
- <input type="hidden" name="file" value="<?php echo $file ?>" />
-</div>
+ <form name="template" id="template" action="templates.php" method="post">
+ <?php wp_nonce_field('edit-file_' . $file) ?>
+ <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+ </div>
<?php if ( is_writeable($real_file) ) : ?>
- <p class="submit">
+ <p class="submit">
<?php
echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
?>
@@ -133,8 +133,8 @@ endif;
<?php else : ?>
<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
<?php endif; ?>
- </form>
- <?php
+ </form>
+ <?php
} else {
echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
}
@@ -144,14 +144,14 @@ endif;
<div class="wrap">
<h2><?php _e('Other Files') ?></h2>
- <p><?php _e('To edit a file, type its name here. You can edit any file <a href="http://codex.wordpress.org/Changing_File_Permissions" title="Read more about making files writable">writable by the server</a>, e.g. CHMOD 666.') ?></p>
- <form name="file" action="templates.php" method="get">
- <input type="text" name="file" />
- <input type="submit" name="submit" value="<?php _e('Edit file &raquo;') ?>" />
- </form>
+ <p><?php _e('To edit a file, type its name here. You can edit any file <a href="http://codex.wordpress.org/Changing_File_Permissions" title="Read more about making files writable">writable by the server</a>, e.g. CHMOD 666.') ?></p>
+ <form name="file" action="templates.php" method="get">
+ <input type="text" name="file" />
+ <input type="submit" name="submit" value="<?php _e('Edit file &raquo;') ?>" />
+ </form>
- <p><?php _e('Note: of course, you can also edit the files/templates in your text editor of choice and upload them. This online editor is only meant to be used when you don&#8217;t have access to a text editor or FTP client.') ?></p>
-</div>
+ <p><?php _e('Note: of course, you can also edit the files/templates in your text editor of choice and upload them. This online editor is only meant to be used when you don&#8217;t have access to a text editor or FTP client.') ?></p>
+</div>
<?php
break;
diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
index 90bae60..6dc6ec3 100644
--- a/wp-admin/theme-editor.php
+++ b/wp-admin/theme-editor.php
@@ -81,7 +81,7 @@ default:
<div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
<?php endif; ?>
<div class="wrap">
- <form name="theme" action="theme-editor.php" method="post">
+ <form name="theme" action="theme-editor.php" method="post">
<?php _e('Select theme to edit:') ?>
<select name="theme" id="theme">
<?php
@@ -107,30 +107,30 @@ default:
}
?>
<div id="templateside">
- <h3><?php printf(__("<strong>'%s'</strong> theme files"), $theme) ?></h3>
+ <h3><?php printf(__("<strong>'%s'</strong> theme files"), $theme) ?></h3>
<?php
if ($allowed_files) :
?>
- <ul>
+ <ul>
<?php foreach($allowed_files as $allowed_file) : ?>
<li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description($allowed_file); ?></a></li>
<?php endforeach; ?>
- </ul>
+ </ul>
<?php endif; ?>
-</div>
+</div>
<?php
if (!$error) {
- ?>
- <form name="template" id="template" action="theme-editor.php" method="post">
- <?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
- <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
- <input type="hidden" name="action" value="update" />
- <input type="hidden" name="file" value="<?php echo $file ?>" />
- <input type="hidden" name="theme" value="<?php echo $theme ?>" />
+ ?>
+ <form name="template" id="template" action="theme-editor.php" method="post">
+ <?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
+ <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
+ <input type="hidden" name="action" value="update" />
+ <input type="hidden" name="file" value="<?php echo $file ?>" />
+ <input type="hidden" name="theme" value="<?php echo $theme ?>" />
</div>
<?php if ( is_writeable($real_file) ) : ?>
- <p class="submit">
+ <p class="submit">
<?php
echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
?>
@@ -138,16 +138,16 @@ if ($allowed_files) :
<?php else : ?>
<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
<?php endif; ?>
- </form>
- <?php
+ </form>
+ <?php
} else {
echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
}
?>
<div class="clear"> &nbsp; </div>
-</div>
+</div>
<?php
break;
}
-include("admin-footer.php") ?>
+include("admin-footer.php") ?>
diff --git a/wp-admin/themes.php b/wp-admin/themes.php
index 9f6d7b5..ee244db 100644
--- a/wp-admin/themes.php
+++ b/wp-admin/themes.php
@@ -138,10 +138,10 @@ if ( is_site_admin() && count($broken_themes) ) {
$theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
echo "
- <tr $theme>
- <td>$title</td>
- <td>$description</td>
- </tr>";
+ <tr $theme>
+ <td>$title</td>
+ <td>$description</td>
+ </tr>";
}
?>
</table>
diff --git a/wp-admin/update-links.php b/wp-admin/update-links.php
index 0ecbdd3..2482deb 100644
--- a/wp-admin/update-links.php
+++ b/wp-admin/update-links.php
@@ -28,13 +28,13 @@ if ( false !== ( $fs = @fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5)
while ( !feof($fs) )
$response .= fgets($fs, 1160); // One TCP-IP packet
fclose($fs);
-
+
$response = explode("\r\n\r\n", $response, 2);
$body = trim( $response[1] );
$body = str_replace(array("\r\n", "\r"), "\n", $body);
-
+
$returns = explode("\n", $body);
-
+
foreach ($returns as $return) :
$time = $wpdb->escape( substr($return, 0, 19) );
$uri = $wpdb->escape( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php
index 4884f7d..1c8c8fd 100644
--- a/wp-admin/upgrade-functions.php
+++ b/wp-admin/upgrade-functions.php
@@ -120,7 +120,7 @@ We hope you enjoy your new weblog. Thanks!
http://wordpress.org/
"), $blog_url, $name, $password);
- @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
+ @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
}
endif;
@@ -137,7 +137,7 @@ function wp_upgrade() {
wp_cache_flush();
make_db_current_silent();
upgrade_all();
- wp_cache_flush();
+ wp_cache_flush();
}
endif;
@@ -187,7 +187,7 @@ function upgrade_100() {
$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
if ($posts) {
foreach($posts as $post) {
- if ('' == $post->post_name) {
+ if ('' == $post->post_name) {
$newtitle = sanitize_title($post->post_title);
$wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
}
@@ -196,7 +196,7 @@ function upgrade_100() {
$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
foreach ($categories as $category) {
- if ('' == $category->category_nicename) {
+ if ('' == $category->category_nicename) {
$newtitle = sanitize_title($category->cat_name);
$wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
}
@@ -251,19 +251,19 @@ function upgrade_101() {
function upgrade_110() {
global $wpdb;
- // Set user_nicename.
+ // Set user_nicename.
$users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
- foreach ($users as $user) {
- if ('' == $user->user_nicename) {
- $newname = sanitize_title($user->user_nickname);
- $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
- }
- }
+ foreach ($users as $user) {
+ if ('' == $user->user_nicename) {
+ $newname = sanitize_title($user->user_nickname);
+ $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
+ }
+ }
$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
foreach ($users as $row) {
if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
- $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
+ $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
}
}
@@ -305,57 +305,57 @@ function upgrade_110() {
}
function upgrade_130() {
- global $wpdb;
+ global $wpdb;
- // Remove extraneous backslashes.
+ // Remove extraneous backslashes.
$posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
if ($posts) {
foreach($posts as $post) {
- $post_content = addslashes(deslash($post->post_content));
- $post_title = addslashes(deslash($post->post_title));
- $post_excerpt = addslashes(deslash($post->post_excerpt));
+ $post_content = addslashes(deslash($post->post_content));
+ $post_title = addslashes(deslash($post->post_title));
+ $post_excerpt = addslashes(deslash($post->post_excerpt));
if ( empty($post->guid) )
$guid = get_permalink($post->ID);
else
$guid = $post->guid;
- $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
+ $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
}
}
- // Remove extraneous backslashes.
+ // Remove extraneous backslashes.
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
if ($comments) {
foreach($comments as $comment) {
- $comment_content = addslashes(deslash($comment->comment_content));
- $comment_author = addslashes(deslash($comment->comment_author));
- $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
+ $comment_content = addslashes(deslash($comment->comment_content));
+ $comment_author = addslashes(deslash($comment->comment_author));
+ $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
}
}
- // Remove extraneous backslashes.
+ // Remove extraneous backslashes.
$links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
if ($links) {
foreach($links as $link) {
- $link_name = addslashes(deslash($link->link_name));
- $link_description = addslashes(deslash($link->link_description));
- $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
+ $link_name = addslashes(deslash($link->link_name));
+ $link_description = addslashes(deslash($link->link_description));
+ $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
}
}
- // The "paged" option for what_to_show is no more.
- if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
- $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
- }
+ // The "paged" option for what_to_show is no more.
+ if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
+ $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
+ }
- $active_plugins = __get_option('active_plugins');
+ $active_plugins = __get_option('active_plugins');
- // If plugins are not stored in an array, they're stored in the old
- // newline separated format. Convert to new format.
- if ( !is_array( $active_plugins ) ) {
- $active_plugins = explode("\n", trim($active_plugins));
- update_option('active_plugins', $active_plugins);
- }
+ // If plugins are not stored in an array, they're stored in the old
+ // newline separated format. Convert to new format.
+ if ( !is_array( $active_plugins ) ) {
+ $active_plugins = explode("\n", trim($active_plugins));
+ update_option('active_plugins', $active_plugins);
+ }
// Obsolete tables
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
@@ -508,7 +508,7 @@ function upgrade_210() {
// Give future posts a post_status of future.
$now = gmdate('Y-m-d H:i:59');
$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
-
+
$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
if ( !empty($posts) )
foreach ( $posts as $post )
@@ -517,7 +517,7 @@ function upgrade_210() {
if ( $wp_current_db_version < 3570 ) {
// Create categories for link categories if a category with the same
// name doesn't exist. Create a map of link cat IDs to cat IDs.
- $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
+ $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
foreach ( $link_cats as $link_cat) {
if ( $cat_id = category_exists($link_cat->cat_name) ) {
$link_cat_id_map[$link_cat->cat_id] = $cat_id;
@@ -536,9 +536,9 @@ function upgrade_210() {
if (!$cat && 0 != $link->link_category) {
$wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
VALUES ('$link->link_id', '$link_cat')");
- }
+ }
}
-
+
// Set default to the last category we grabbed during the upgrade loop.
update_option('default_link_category', $default_link_cat);
@@ -557,21 +557,21 @@ function upgrade_210() {
// General
function maybe_create_table($table_name, $create_ddl) {
- global $wpdb;
- foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
- if ($table == $table_name) {
- return true;
- }
- }
- //didn't find it try to create it.
- $q = $wpdb->query($create_ddl);
- // we cannot directly tell that whether this succeeded!
- foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
- if ($table == $table_name) {
- return true;
- }
- }
- return false;
+ global $wpdb;
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ return false;
}
function drop_index($table, $index) {
@@ -600,22 +600,22 @@ function add_clean_index($table, $index) {
** false on error
*/
function maybe_add_column($table_name, $column_name, $create_ddl) {
- global $wpdb, $debug;
- foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
- if ($debug) echo("checking $column == $column_name<br />");
- if ($column == $column_name) {
- return true;
- }
- }
- //didn't find it try to create it.
- $q = $wpdb->query($create_ddl);
- // we cannot directly tell that whether this succeeded!
- foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
- if ($column == $column_name) {
- return true;
- }
- }
- return false;
+ global $wpdb, $debug;
+ foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+ if ($debug) echo("checking $column == $column_name<br />");
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ return false;
}
@@ -624,7 +624,7 @@ function get_alloptions_110() {
global $wpdb;
if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
foreach ($options as $option) {
- // "When trying to design a foolproof system,
+ // "When trying to design a foolproof system,
// never underestimate the ingenuity of the fools :)" -- Dougal
if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
@@ -655,20 +655,20 @@ function __get_option($setting) {
}
function deslash($content) {
- // Note: \\\ inside a regex denotes a single backslash.
+ // Note: \\\ inside a regex denotes a single backslash.
- // Replace one or more backslashes followed by a single quote with
- // a single quote.
- $content = preg_replace("/\\\+'/", "'", $content);
+ // Replace one or more backslashes followed by a single quote with
+ // a single quote.
+ $content = preg_replace("/\\\+'/", "'", $content);
- // Replace one or more backslashes followed by a double quote with
- // a double quote.
- $content = preg_replace('/\\\+"/', '"', $content);
+ // Replace one or more backslashes followed by a double quote with
+ // a double quote.
+ $content = preg_replace('/\\\+"/', '"', $content);
- // Replace one or more backslashes with one backslash.
- $content = preg_replace("/\\\+/", "\\", $content);
+ // Replace one or more backslashes with one backslash.
+ $content = preg_replace("/\\\+/", "\\", $content);
- return $content;
+ return $content;
}
function dbDelta($queries, $execute = true) {
@@ -835,7 +835,7 @@ function dbDelta($queries, $execute = true) {
$index_columns .= '('.$column_data['subpart'].')';
}
}
- // Add the column list to the index create string
+ // Add the column list to the index create string
$index_string .= ' ('.$index_columns.')';
if(!(($aindex = array_search($index_string, $indices)) === false)) {
diff --git a/wp-admin/upgrade-schema.php b/wp-admin/upgrade-schema.php
index 1875545..2e2cb1a 100644
--- a/wp-admin/upgrade-schema.php
+++ b/wp-admin/upgrade-schema.php
@@ -300,7 +300,7 @@ function populate_options() {
add_option('uploads_use_yearmonth_folders', 1);
add_option('upload_path', 'wp-content/uploads');
}
-
+
// 2.0.3
add_option('secret', md5(uniqid(microtime())));
diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php
index c0a4f7e..e44f07a 100644
--- a/wp-admin/upgrade.php
+++ b/wp-admin/upgrade.php
@@ -61,6 +61,6 @@ switch($step) {
<?php
break;
}
-?>
+?>
</body>
</html>
diff --git a/wp-admin/upload-functions.php b/wp-admin/upload-functions.php
index 623daeb..3900c6e 100644
--- a/wp-admin/upload-functions.php
+++ b/wp-admin/upload-functions.php
@@ -13,9 +13,9 @@ function wp_upload_display( $dims = false, $href = '' ) {
$class = 'text';
$innerHTML = get_attachment_innerHTML( $id, false, $dims );
- if ( $image_src = strstr($innerHTML, 'src="') ) {
- $image_src = explode('"', $image_src);
- $image_src = $image_src[1];
+ if ( $image_src = strstr($innerHTML, 'src=') ) {
+ preg_match("/src=(\"|')(.+?)\\1/", $image_src, $matches);
+ $image_src = $matches[2];
$image_rel = wp_make_link_relative($image_src);
$class = 'image';
$innerHTML = '&nbsp;' . str_replace($image_src, $image_rel, $innerHTML);
@@ -358,14 +358,15 @@ add_action( 'upload_files_browse-all', 'wp_upload_tab_browse_action' );
function wp_upload_admin_head() {
global $wp_locale;
- echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
+ echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload.css?version=' . get_bloginfo('version') . "a' type='text/css' />\n";
if ( 'rtl' == $wp_locale->text_direction )
- echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload-rtl.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
+ echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload-rtl.css?version=' . get_bloginfo('version') . "a' type='text/css' />\n";
if ( 'inline' == @$_GET['style'] ) {
- echo "<style type='text/css'>\n";
- echo "\tbody { height: 15em; overflow: hidden; }\n";
- echo "\t#upload-content { overflow-y: auto; }\n";
- echo "\t#upload-file { position: absolute; }\n";
+ echo "<style type='text/css' media='screen'>\n";
+ echo "\t#upload-menu { position: absolute; z-index: 2; }\n";
+ echo "\tbody > #upload-menu { position: fixed; }\n";
+ echo "\t#upload-content { top: 2em; }\n";
+ echo "\t#upload-file { position: absolute; top: 15px; }\n";
echo "</style>";
}
}
diff --git a/wp-admin/upload-js.php b/wp-admin/upload-js.php
index c92439f..ca51e3f 100644
--- a/wp-admin/upload-js.php
+++ b/wp-admin/upload-js.php
@@ -74,7 +74,7 @@ addLoadEvent( function() {
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='Browse your files' class='back'>&laquo; Back</a>";
} else {
- h += "<a href='#' onclick='theFileList.cancelView()' title='Browse your files' class='back'>&laquo; Back</a>";
+ h += "<a href='#' onclick='return theFileList.cancelView();' title='Browse your files' class='back'>&laquo; Back</a>";
}
h += "<div id='file-title'>"
if ( !this.currentImage.isImage )
@@ -82,7 +82,7 @@ addLoadEvent( function() {
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
- h += "<a href='#' onclick='theFileList.editView(" + id + ")'>Edit</a>"
+ h += "<a href='#' onclick='return theFileList.editView(" + id + ");'>Edit</a>"
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
@@ -97,20 +97,20 @@ addLoadEvent( function() {
h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>";
h += "<table>";
if ( this.currentImage.thumb ) {
- h += "<tr><th style='padding-bottom:.5em'>Show:</th><td style='padding-bottom:.5em'>";
- h += "<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' checked='checked' /> Thumbnail</label><br />";
- h += "<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> Full size</label>";
+ h += "<tr><th style='padding-bottom:.5em'><?php echo addslashes(__('Show:')); ?></th><td style='padding-bottom:.5em'>";
+ h += "<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' checked='checked' /> <?php echo addslashes(__('Thumbnail')); ?></label><br />";
+ h += "<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> <?php echo addslashes(__('Full size')); ?></label>";
h += "</td></tr>";
}
- h += "<tr><th>Link to:</th><td>";
- h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> File</label><br />";
- h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> Page</label><br />";
- h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> None</label>";
+ h += "<tr><th><?php echo addslashes(__('Link to:')); ?></th><td>";
+ h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> <?php echo addslashes(__('File')); ?></label><br />";
+ h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> <?php echo addslashes(__('Page')); ?></label><br />";
+ h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> <?php echo addslashes(__('None')); ?></label>";
h += "</td></tr>";
h += "<tr><td colspan='2'><p class='submit'>";
- h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='Send to editor &raquo;' />";
+ h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='<?php echo addslashes(__('Send to editor')); ?> &raquo;' />";
h += "</p></td></tr></table>";
h += "</form>";
@@ -136,7 +136,7 @@ addLoadEvent( function() {
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='Browse your files' class='back'>&laquo; Back</a>";
} else {
- h += "<a href='#' onclick='theFileList.cancelView()' title='Browse your files' class='back'>&laquo; Back</a>";
+ h += "<a href='#' onclick='return theFileList.cancelView();' title='Browse your files' class='back'>&laquo; Back</a>";
}
h += "<div id='file-title'>"
if ( !this.currentImage.isImage )
@@ -144,7 +144,7 @@ addLoadEvent( function() {
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
- h += "<a href='#' onclick='theFileList.imageView(" + id + ")'>Insert</a>"
+ h += "<a href='#' onclick='return theFileList.imageView(" + id + ");'>Insert</a>"
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
@@ -221,7 +221,7 @@ addLoadEvent( function() {
display = 'full';
if ( 'none' != link )
- h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID + "'" ) ) + "' title='" + this.currentImage.title + "'>";
+ h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID ) ) + "' title='" + this.currentImage.title + "'>";
if ( display )
h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
else
@@ -233,9 +233,10 @@ addLoadEvent( function() {
if ( !win )
win = top;
tinyMCE = win.tinyMCE;
- if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') )
- win.tinyMCE.execCommand('mceInsertContent', false, h);
- else
+ if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) {
+ tinyMCE.selectedInstance.getWin().focus();
+ tinyMCE.execCommand('mceInsertContent', false, h);
+ } else
win.edInsertContent(win.edCanvas, h);
if ( !this.ID )
this.cancelView();
@@ -243,7 +244,7 @@ addLoadEvent( function() {
},
deleteFile: function(id) {
- if ( confirm("Are you sure you want to delete the file '" + this.currentImage.title + "'?\nClick ok to delete or cancel to go back.") ) {
+ if ( confirm("<?php printf(js_escape(__("Are you sure you want to delete the file '%s'?\nClick ok to delete or cancel to go back.")), '" + this.currentImage.title + "'); ?>") ) {
$('action-value').value = 'delete';
$('upload-file').submit();
return true;
diff --git a/wp-admin/upload-rtl.css b/wp-admin/upload-rtl.css
index a085c86..cf1a7c2 100644
--- a/wp-admin/upload-rtl.css
+++ b/wp-admin/upload-rtl.css
@@ -1,5 +1,16 @@
+#upload-menu li a.upload-tab-link {
+ float: right;
+ margin: 0 .75em 0 0;
+}
+
table { float: right; }
+#upload-menu li #current-tab-nav {
+ float: right;
+ padding: 5px 0 0 5px;
+ margin-right: -5px;
+}
+
#upload-file th, #the-attachment-links textarea { text-align: left; }
h2 { margin: 0 0 0 .2em; }
@@ -9,12 +20,11 @@ h2 { margin: 0 0 0 .2em; }
#upload-file-view { padding: 0 75px 0 0; }
#upload-menu li {
- margin: 0 .75em 0 0;
display: block;
float: right;
}
-#upload-menu .current div {
+#upload-menu li.current {
border-right: 0;
border-left: 2px solid #448abd;
}
diff --git a/wp-admin/upload.css b/wp-admin/upload.css
index 601f7e7..a74ec18 100644
--- a/wp-admin/upload.css
+++ b/wp-admin/upload.css
@@ -3,45 +3,60 @@ body { background: #f9fcfe; }
.upload-file-data { display: none; }
#upload-menu {
- background: #247fab;
- margin: 0px;
+ border-top: 2em solid #247fab;
+ margin: 0;
padding: 0;
+ height: 0;
list-style: none;
- height: 2em;
- border-bottom: 1px solid #448abd;
width: 100%;
}
-#upload-menu li { margin: 0 0 0 .75em; }
+body > #upload-menu { border-bottom: 7px solid #fff; }
-#upload-menu li div {
- padding: 5px;
+#upload-menu li {
+ margin: 0;
+ position: relative;
+ top: -2em;
+ padding-bottom: 5px;
+ border: none;
border-top: 3px solid #247fab;
}
-#upload-menu li a {
+#upload-menu li a.upload-tab-link {
+ margin-left: 0.75em;
+ padding: 5px 5px 0;
+ display: block;
+ float: left;
+ height: 100%;
text-decoration: none;
border-bottom: none;
color: #fff;
}
-#upload-menu li span a.page-numbers { color: #00019b; }
-
-#upload-menu .current div {
- background: #f9fcfe;
+#upload-menu li.current {
border-right: 2px solid #448abd;
color: #000;
}
-#upload-menu .current div a, #upload-menu div:hover a {
+#upload-menu li.current a.upload-tab-link, #upload-menu li a:hover {
+ background: #f9fcfe;
color: #000;
}
-#upload-menu div:hover {
- background: #f9fcfe;
- color: #000;
+#upload-menu li #current-tab-nav {
+ float: left;
+ padding: 5px 5px 0 0;
+ margin-left: -5px;
+}
+
+#upload-menu li span .page-numbers {
+ padding: 0;
+ border: none;
}
+#upload-menu li span a.page-numbers { color: #00019b; }
+#upload-menu li span a.page-numbers:hover { text-decoration: underline; }
+
#upload-content {
position: relative;
clear: both;
diff --git a/wp-admin/upload.php b/wp-admin/upload.php
index acf3a75..53d1e56 100644
--- a/wp-admin/upload.php
+++ b/wp-admin/upload.php
@@ -14,8 +14,6 @@ if ( !$tab )
do_action( "upload_files_$tab" );
-add_action( 'admin_head', 'wp_upload_admin_head' );
-
$pid = 0;
if ( $post_id < 0 )
$pid = $post_id;
@@ -37,7 +35,7 @@ if ( $pid ) {
$wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() ));
-if ( !function_exists($wp_upload_tabs[$tab][2]) ) {
+if ( !is_callable($wp_upload_tabs[$tab][2]) ) {
$to_tab = isset($wp_upload_tabs['upload']) ? 'upload' : 'browse-all';
wp_redirect( add_query_arg( 'tab', $to_tab ) );
exit;
@@ -78,12 +76,12 @@ endif;
echo "<ul id='upload-menu'>\n";
foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check
- $class = 'upload-tab';
$href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') );
if ( isset($tab_array[4]) && is_array($tab_array[4]) )
add_query_arg( $tab_array[4], $href );
$_href = wp_specialchars( $href, 1 );
$page_links = '';
+ $class = 'upload-tab alignleft';
if ( $tab == $t ) {
$class .= ' current';
if ( $tab_array[3] ) {
@@ -107,7 +105,7 @@ foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the curr
}
}
- echo "\t<li class='$class alignleft'><div><a href='$_href' title='{$tab_array[0]}'>{$tab_array[0]}</a>$page_links</div></li>\n";
+ echo "\t<li class='$class'><a href='$_href' class='upload-tab-link' title='{$tab_array[0]}'>{$tab_array[0]}</a>$page_links</li>\n";
}
unset($t, $tab_array, $href, $_href, $page_links, $total, $per, $class);
echo "</ul>\n\n";
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
index e1bdcc5..cc5d758 100644
--- a/wp-admin/user-edit.php
+++ b/wp-admin/user-edit.php
@@ -192,13 +192,13 @@ if ( $show_password_fields ) :
<?php do_action('edit_user_profile'); ?>
<br clear="all" />
- <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
- <?php
- if(count($profileuser->caps) > count($profileuser->roles)):
- ?>
- <tr>
- <th scope="row"><?php _e('Additional Capabilities:') ?></th>
- <td><?php
+ <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">
+ <?php
+ if(count($profileuser->caps) > count($profileuser->roles)):
+ ?>
+ <tr>
+ <th scope="row"><?php _e('Additional Capabilities:') ?></th>
+ <td><?php
$output = '';
foreach($profileuser->caps as $cap => $value) {
if(!$wp_roles->is_role($cap)) {
@@ -208,15 +208,15 @@ if ( $show_password_fields ) :
}
echo $output;
?></td>
- </tr>
- <?php
- endif;
- ?>
- </table>
+ </tr>
+ <?php
+ endif;
+ ?>
+ </table>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
- <input type="submit" value="<?php _e('Update User &raquo;') ?>" name="submit" />
+ <input type="submit" value="<?php _e('Update User &raquo;') ?>" name="submit" />
</p>
</form>
</div>
diff --git a/wp-admin/users.php b/wp-admin/users.php
index 51e2b31..46ba6ca 100644
--- a/wp-admin/users.php
+++ b/wp-admin/users.php
@@ -123,6 +123,7 @@ case 'promote':
if (empty($_POST['users'])) {
wp_redirect($redirect);
+ exit();
}
if ( !current_user_can('edit_users') )
@@ -134,7 +135,7 @@ case 'promote':
if ( ! current_user_can('edit_user', $id) )
wp_die(__('You can&#8217;t edit that user.'));
// The new role of the current user must also have edit_users caps
- if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
+ if($id == $current_user->ID && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
$update = 'err_admin_role';
continue;
}
@@ -144,6 +145,7 @@ case 'promote':
}
wp_redirect(add_query_arg('update', $update, $redirect));
+ exit();
break;
@@ -153,6 +155,7 @@ case 'dodelete':
if ( empty($_POST['users']) ) {
wp_redirect($redirect);
+ exit();
}
if ( !current_user_can('delete_users') )
@@ -166,7 +169,7 @@ case 'dodelete':
if ( ! current_user_can('delete_user', $id) )
wp_die(__('You can&#8217;t delete that user.'));
- if($id == $current_user->id) {
+ if($id == $current_user->ID) {
$update = 'err_admin_del';
continue;
}
@@ -181,9 +184,9 @@ case 'dodelete':
++$delete_count;
}
- $redirect = add_query_arg('delete_count', $delete_count, $redirect);
-
- wp_redirect(add_query_arg('update', $update, $redirect));
+ $redirect = add_query_arg( array('delete_count' => $delete_count, 'update' => $update), $redirect);
+ wp_redirect($redirect);
+ exit();
break;
@@ -191,8 +194,10 @@ case 'delete':
wp_die(__('This function is disabled.'));
check_admin_referer('bulk-users');
- if ( empty($_POST['users']) )
+ if ( empty($_POST['users']) ) {
wp_redirect($redirect);
+ exit();
+ }
if ( !current_user_can('delete_users') )
$errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
@@ -212,7 +217,7 @@ case 'delete':
$go_delete = false;
foreach ( (array) $userids as $id ) {
$user = new WP_User($id);
- if ( $id == $current_user->id ) {
+ if ( $id == $current_user->ID ) {
echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
} else {
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
@@ -222,7 +227,7 @@ case 'delete':
$all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities' ORDER BY user_login");
$user_dropdown = '<select name="reassign_user">';
foreach ( (array) $all_logins as $login )
- if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) )
+ if ( $login->ID == $current_user->ID || !in_array($login->ID, $userids) )
$user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
$user_dropdown .= '</select>';
?>
@@ -329,8 +334,8 @@ case 'adduser':
$add_user_errors = $user_id;
else {
$new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true));
- $redirect = add_query_arg('usersearch', $new_user_login, $redirect);
- wp_redirect(add_query_arg('update', $update, $redirect) . '#user-' . $user_id);
+ $redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect );
+ wp_redirect( $redirect . '#user-' . $user_id );
die();
}
diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css
index 6fcffa8..010dc60 100644
--- a/wp-admin/wp-admin.css
+++ b/wp-admin/wp-admin.css
@@ -219,9 +219,8 @@ textarea, input, select {
border-style: none;
padding: 0px;
margin-bottom: 16px;
- height: 17em;
+ height: 18em;
width: 100%;
-/* overflow-y: hidden;*/
}
form#upload th {
@@ -297,7 +296,7 @@ form#upload #post_content {
}
.commentlist li {
- border-bottom: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
padding: 1em 1em .2em;
margin: 0;
}
@@ -1006,8 +1005,8 @@ input.delete:hover {
}
/* A handy div class for hiding controls.
- Some browsers will disable them when you
- set display:none; */
+Some browsers will disable them when you
+set display:none; */
.zerosize {
height: 0px;
width: 0px;
@@ -1047,9 +1046,9 @@ input.delete:hover {
}
/****************************************************************
- avoid padding, margins or borders on dbx-box,
- to reduce visual discrepancies between it and the clone.
- overall, dbx-box is best left as visually unstyled as possible
+avoid padding, margins or borders on dbx-box,
+to reduce visual discrepancies between it and the clone.
+overall, dbx-box is best left as visually unstyled as possible
*****************************************************************/
.dbx-box {
margin:0;
diff --git a/wp-admin/xfn.js b/wp-admin/xfn.js
index 3cdf608..9bcde19 100644
--- a/wp-admin/xfn.js
+++ b/wp-admin/xfn.js
@@ -10,10 +10,10 @@ function GetElementsWithClassName(elementName, className) {
}
function meChecked() {
- var undefined;
- var eMe = document.getElementById('me');
- if (eMe == undefined) return false;
- else return eMe.checked;
+ var undefined;
+ var eMe = document.getElementById('me');
+ if (eMe == undefined) return false;
+ else return eMe.checked;
}
function upit() {
diff --git a/wp-atom.php b/wp-atom.php
index 2069bdf..0eacfe3 100644
--- a/wp-atom.php
+++ b/wp-atom.php
@@ -11,11 +11,11 @@ $more = 1;
?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<feed version="0.3"
- xmlns="http://purl.org/atom/ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xml:lang="<?php echo get_option('rss_language'); ?>"
- <?php do_action('atom_ns'); ?>
- >
+ xmlns="http://purl.org/atom/ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xml:lang="<?php echo get_option('rss_language'); ?>"
+ <?php do_action('atom_ns'); ?>
+>
<title><?php bloginfo_rss('name') ?></title>
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
<tagline><?php bloginfo_rss("description") ?></tagline>
@@ -23,9 +23,9 @@ $more = 1;
<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright>
<generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
<?php do_action('atom_head'); ?>
- <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+ <?php while (have_posts()) : the_post(); ?>
<entry>
- <author>
+ <author>
<name><?php the_author() ?></name>
</author>
<title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title>
@@ -33,7 +33,7 @@ $more = 1;
<id><?php the_guid(); ?></id>
<modified><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></modified>
<issued><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></issued>
- <?php the_category_rss('rdf') ?>
+ <?php the_category_rss('rdf') ?>
<summary type="text/plain" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if ( !get_option('rss_use_excerpt') ) : ?>
<content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
@@ -41,5 +41,5 @@ $more = 1;
<?php rss_enclosure(); ?>
<?php do_action('atom_entry'); ?>
</entry>
- <?php $items_count++; if (($items_count == get_option('posts_per_rss')) && empty($m)) { break; } } } ?>
+ <?php endwhile ; ?>
</feed>
diff --git a/wp-commentsrss2.php b/wp-commentsrss2.php
index 3a5d7bf..a0434d9 100644
--- a/wp-commentsrss2.php
+++ b/wp-commentsrss2.php
@@ -1,4 +1,4 @@
-<?php
+<?php
if (empty($wp)) {
require_once('wp-config.php');
@@ -58,12 +58,13 @@ if (have_posts()) :
$title = apply_filters('the_title_rss', $title);
printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
} else {
- printf(__('by: %s'), get_comment_author_rss());
+ printf(__('By: %s'), get_comment_author_rss());
} ?></title>
<link><?php comment_link() ?></link>
+ <author><?php echo get_comment_author_rss() ?></author>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
<guid><?php comment_link() ?></guid>
- <?php
+ <?php
if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
?>
<description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
@@ -73,12 +74,12 @@ if (have_posts()) :
?>
<description><?php comment_text_rss() ?></description>
<content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
- <?php
- } // close check for password
+ <?php
+ } // close check for password
?>
</item>
-<?php
- }
+<?php
+ }
}
}
endwhile; endif;
diff --git a/wp-content/themes/classic/comments-popup.php b/wp-content/themes/classic/comments-popup.php
index b39c8c5..5d9101b 100644
--- a/wp-content/themes/classic/comments-popup.php
+++ b/wp-content/themes/classic/comments-popup.php
@@ -1,7 +1,7 @@
-<?php
+<?php
/* Don't remove these lines. */
add_filter('comment_text', 'popuplinks');
-foreach ($posts as $post) { start_wp();
+while( have_posts()) : the_post();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -93,11 +93,11 @@ if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH
<div><strong><a href="javascript:window.close()"><?php _e("Close this window."); ?></a></strong></div>
<?php // if you delete this the sky will fall on your head
-}
+endwhile;
?>
<!-- // this is just the end of the motor - don't touch that line either :) -->
-<?php //} ?>
+<?php //} ?>
<p class="credit"><?php timer_stop(1); ?> <?php echo sprintf(__("<cite>Powered by <a href=\"http://wordpress.org\" title=\"%s\"><strong>Wordpress</strong></a></cite>"),__("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></p>
<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
<script type="text/javascript">
diff --git a/wp-content/themes/classic/comments.php b/wp-content/themes/classic/comments.php
index 860e634..6154aed 100644
--- a/wp-content/themes/classic/comments.php
+++ b/wp-content/themes/classic/comments.php
@@ -2,7 +2,7 @@
<p><?php _e('Enter your password to view comments.'); ?></p>
<?php return; endif; ?>
-<h2 id="comments"><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?>
+<h2 id="comments"><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?>
<?php if ( comments_open() ) : ?>
<a href="#postcomment" title="<?php _e("Leave a comment"); ?>">&raquo;</a>
<?php endif; ?>
@@ -25,7 +25,7 @@
<p><?php _e('No comments yet.'); ?></p>
<?php endif; ?>
-<p><?php comments_rss_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?>
+<p><?php comments_rss_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?>
<?php if ( pings_open() ) : ?>
<a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Universal Resource Locator">URL</abbr>'); ?></a>
<?php endif; ?>
diff --git a/wp-content/themes/classic/header.php b/wp-content/themes/classic/header.php
index 7052ae7..92c995f 100644
--- a/wp-content/themes/classic/header.php
+++ b/wp-content/themes/classic/header.php
@@ -17,7 +17,7 @@
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
- <?php wp_get_archives('type=monthly&format=link'); ?>
+ <?php wp_get_archives('type=monthly&format=link'); ?>
<?php //comments_popup_script(); // off by default ?>
<?php wp_head(); ?>
</head>
diff --git a/wp-content/themes/classic/sidebar.php b/wp-content/themes/classic/sidebar.php
index 8e34c73..49d476f 100644
--- a/wp-content/themes/classic/sidebar.php
+++ b/wp-content/themes/classic/sidebar.php
@@ -26,12 +26,12 @@
</form>
</li>
<li id="archives"><?php _e('Archives:'); ?>
- <ul>
+ <ul>
<?php wp_get_archives('type=monthly'); ?>
- </ul>
+ </ul>
</li>
<li id="meta"><?php _e('Meta:'); ?>
- <ul>
+ <ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="feed:<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
diff --git a/wp-content/themes/default/archives.php b/wp-content/themes/default/archives.php
index de6c07c..dba8dbd 100644
--- a/wp-content/themes/default/archives.php
+++ b/wp-content/themes/default/archives.php
@@ -11,14 +11,14 @@ Template Name: Archives
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
<h2>Archives by Month:</h2>
- <ul>
- <?php wp_get_archives('type=monthly'); ?>
- </ul>
+ <ul>
+ <?php wp_get_archives('type=monthly'); ?>
+ </ul>
<h2>Archives by Subject:</h2>
- <ul>
- <?php wp_list_categories(); ?>
- </ul>
+ <ul>
+ <?php wp_list_categories(); ?>
+ </ul>
</div>
diff --git a/wp-content/themes/default/comments-popup.php b/wp-content/themes/default/comments-popup.php
index 42c9bc5..46662b2 100644
--- a/wp-content/themes/default/comments-popup.php
+++ b/wp-content/themes/default/comments-popup.php
@@ -1,7 +1,7 @@
-<?php
+<?php
/* Don't remove these lines. */
add_filter('comment_text', 'popuplinks');
-foreach ($posts as $post) { start_wp();
+while ( have_posts()) : the_post();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -93,11 +93,11 @@ if (!empty($post->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $pos
<div><strong><a href="javascript:window.close()">Close this window.</a></strong></div>
<?php // if you delete this the sky will fall on your head
-}
+endwhile;
?>
<!-- // this is just the end of the motor - don't touch that line either :) -->
-<?php //} ?>
+<?php //} ?>
<p class="credit"><?php timer_stop(1); ?> <cite>Powered by <a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>Wordpress</strong></a></cite></p>
<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
<script type="text/javascript">
diff --git a/wp-content/themes/default/comments.php b/wp-content/themes/default/comments.php
index ecf0b34..8352f0f 100644
--- a/wp-content/themes/default/comments.php
+++ b/wp-content/themes/default/comments.php
@@ -2,25 +2,25 @@
if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
- if (!empty($post->post_password)) { // if there's a password
- if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
- ?>
+ if (!empty($post->post_password)) { // if there's a password
+ if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
+ ?>
- <p class="nocomments">This post is password protected. Enter the password to view comments.<p>
+ <p class="nocomments">This post is password protected. Enter the password to view comments.<p>
- <?php
- return;
- }
- }
+ <?php
+ return;
+ }
+ }
- /* This variable is for alternating comment background */
- $oddcomment = 'alt';
+ /* This variable is for alternating comment background */
+ $oddcomment = 'alt';
?>
<!-- You can start editing here. -->
<?php if ($comments) : ?>
- <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>
+ <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>
<ol class="commentlist">
@@ -50,7 +50,7 @@
<?php else : // this is displayed if there are no comments so far ?>
- <?php if ('open' == $post->comment_status) : ?>
+ <?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
diff --git a/wp-content/themes/default/header.php b/wp-content/themes/default/header.php
index e642de4..774d6d2 100644
--- a/wp-content/themes/default/header.php
+++ b/wp-content/themes/default/header.php
@@ -14,13 +14,13 @@
<style type="text/css" media="screen">
-<?php
+<?php
// Checks to see whether it needs a sidebar or not
-if ( !$withcomments && !is_single() ) {
+if ( !$withcomments && !is_single() ) {
?>
#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; }
<?php } else { // No sidebar ?>
- #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
+ #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
<?php } ?>
</style>
diff --git a/wp-content/themes/default/page.php b/wp-content/themes/default/page.php
index 9c3838d..8580681 100644
--- a/wp-content/themes/default/page.php
+++ b/wp-content/themes/default/page.php
@@ -2,7 +2,7 @@
<div id="content" class="narrowcolumn">
- <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+ <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
@@ -12,7 +12,7 @@
</div>
</div>
- <?php endwhile; endif; ?>
+ <?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
diff --git a/wp-content/themes/default/sidebar.php b/wp-content/themes/default/sidebar.php
index a45b1bb..64238c1 100644
--- a/wp-content/themes/default/sidebar.php
+++ b/wp-content/themes/default/sidebar.php
@@ -32,11 +32,11 @@
<p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives
for <?php the_time('F, Y'); ?>.</p>
- <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
+ <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives
for the year <?php the_time('Y'); ?>.</p>
- <?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
+ <?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
<p>You have searched the <a href="<?php echo bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives
for <strong>'<?php the_search_query(); ?>'</strong>. If you are unable to find anything in these search results, you can try one of these links.</p>
diff --git a/wp-content/themes/default/single.php b/wp-content/themes/default/single.php
index ee040d5..967a065 100644
--- a/wp-content/themes/default/single.php
+++ b/wp-content/themes/default/single.php
@@ -2,7 +2,7 @@
<div id="content" class="widecolumn">
- <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+ <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="navigation">
<div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
@@ -23,10 +23,10 @@
<?php /* This is commented, because it requires a little adjusting sometimes.
You'll need to download this plugin, and follow the instructions:
http://binarybonsai.com/archives/2004/08/17/time-since-plugin/ */
- /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?>
+ /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?>
on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
and is filed under <?php the_category(', ') ?>.
- You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed.
+ You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed.
<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
// Both Comments and Pings are open ?>
diff --git a/wp-cron.php b/wp-cron.php
index 45cb9f3..36d7662 100644
--- a/wp-cron.php
+++ b/wp-cron.php
@@ -6,6 +6,11 @@ require_once('wp-config.php');
if ( $_GET['check'] != md5(DB_PASS . '187425') )
exit;
+if ( get_option('doing_cron') > time() )
+ exit;
+
+update_option('doing_cron', time() + 30);
+
$crons = _get_cron_array();
$keys = array_keys($crons);
if (!is_array($crons) || $keys[0] > time())
@@ -14,14 +19,17 @@ foreach ($crons as $timestamp => $cronhooks) {
if ($timestamp > time()) break;
foreach ($cronhooks as $hook => $keys) {
foreach ($keys as $key => $args) {
- do_action_ref_array($hook, $args['args']);
$schedule = $args['schedule'];
if ($schedule != false) {
$new_args = array($timestamp, $schedule, $hook, $args['args']);
call_user_func_array('wp_reschedule_event', $new_args);
}
wp_unschedule_event($timestamp, $hook, $args['args']);
+ do_action_ref_array($hook, $args['args']);
}
}
}
+
+update_option('doing_cron', 0);
+
?>
diff --git a/wp-feed.php b/wp-feed.php
index a27fa33..260ddd4 100644
--- a/wp-feed.php
+++ b/wp-feed.php
@@ -1,8 +1,8 @@
<?php
if (empty($doing_rss)) {
- $doing_rss = 1;
- require(dirname(__FILE__) . '/wp-blog-header.php');
+ $doing_rss = 1;
+ require(dirname(__FILE__) . '/wp-blog-header.php');
}
do_feed();
diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php
index a98bc63..c76d44f 100644
--- a/wp-includes/author-template.php
+++ b/wp-includes/author-template.php
@@ -188,7 +188,7 @@ function wp_list_authors($args = '') {
$query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
$authors = $wpdb->get_results($query);
- foreach ( $authors as $author ) {
+ foreach ( (array) $authors as $author ) {
$author = get_userdata( $author->ID );
$posts = get_usernumposts($author->ID);
$name = $author->nickname;
diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php
index 990aae1..93a4cf4 100644
--- a/wp-includes/bookmark-template.php
+++ b/wp-includes/bookmark-template.php
@@ -146,7 +146,7 @@ function get_links($category = -1,
}
function get_linkrating($link) {
- return apply_filters('link_rating', $link->link_rating);
+ return apply_filters('link_rating', $link->link_rating);
}
/** function get_linkcatname()
@@ -336,18 +336,20 @@ function wp_list_bookmarks($args = '') {
$bookmarks = get_bookmarks("limit=$limit&category={$cat->cat_ID}&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_invisible&show_updated=$show_updated");
if ( empty($bookmarks) )
continue;
- $output .= "<li id='linkcat-$cat->cat_ID' class='$class'>$title_before$cat->cat_name$title_after\n\t<ul>\n";
+ $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->cat_ID", $class), $category_before);
+ $output .= "$title_before$cat->cat_name$title_after\n\t<ul>\n";
$output .= _walk_bookmarks($bookmarks, $r);
- $output .= "\n\t</ul>\n</li>\n";
+ $output .= "\n\t</ul>\n$category_after\n";
}
} else {
//output one single list using title_li for the title
$bookmarks = get_bookmarks("limit=$limit&category=$category&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_invisible&show_updated=$show_updated");
if ( !empty($bookmarks) ) {
- $output .= "<li id='linkuncat' class='$class'>$title_before$title_li$title_after\n\t<ul>\n";
+ $output .= str_replace(array('%id', '%class'), array("linkuncat", $class), $category_before);
+ $output .= "$title_before$title_li$title_after\n\t<ul>\n";
$output .= _walk_bookmarks($bookmarks, $r);
- $output .= "\n\t</ul>\n</li>\n";
+ $output .= "\n\t</ul>\n$category_after\n";
}
}
diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php
index 306a33f..2824a89 100644
--- a/wp-includes/bookmark.php
+++ b/wp-includes/bookmark.php
@@ -35,6 +35,11 @@ function get_bookmarks($args = '') {
$r = array_merge($defaults, $r);
extract($r);
+ $key = md5( serialize( $r ) );
+ if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) )
+ if ( isset( $cache[ $key ] ) )
+ return apply_filters('get_bookmarks', $cache[ $key ], $r );
+
$inclusions = '';
if ( !empty($include) ) {
$exclude = ''; //ignore exclude, category, and category_name params if using include
@@ -128,7 +133,18 @@ function get_bookmarks($args = '') {
$query .= " LIMIT $limit";
$results = $wpdb->get_results($query);
+
+ $cache[ $key ] = $results;
+ wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
+
return apply_filters('get_bookmarks', $results, $r);
}
+function delete_get_bookmark_cache() {
+ wp_cache_delete( 'get_bookmarks', 'bookmark' );
+}
+add_action( 'add_link', 'delete_get_bookmark_cache' );
+add_action( 'edit_link', 'delete_get_bookmark_cache' );
+add_action( 'delete_link', 'delete_get_bookmark_cache' );
+
?>
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index 3a48521..6880624 100644
--- a/wp-includes/cache.php
+++ b/wp-includes/cache.php
@@ -30,9 +30,7 @@ function wp_cache_get($id, $flag = '') {
}
function wp_cache_init() {
- global $wp_object_cache;
-
- $wp_object_cache = new WP_Object_Cache();
+ $GLOBALS['wp_object_cache'] =& new WP_Object_Cache();
}
function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
@@ -67,7 +65,7 @@ class WP_Object_Cache {
var $secret = '';
function acquire_lock() {
- // Acquire a write lock.
+ // Acquire a write lock.
$this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
if ( false == $this->mutex)
return false;
@@ -260,11 +258,11 @@ class WP_Object_Cache {
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;
diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
index adc1827..273dccc 100644
--- a/wp-includes/capabilities.php
+++ b/wp-includes/capabilities.php
@@ -130,7 +130,8 @@ class WP_Role {
class WP_User {
var $data;
- var $id = 0;
+ var $ID = 0;
+ var $id = 0; // Deprecated, use $ID instead.
var $caps = array();
var $cap_key;
var $roles = array();
@@ -193,7 +194,7 @@ class WP_User {
function add_role($role) {
$this->caps[$role] = true;
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
$this->get_role_caps();
$this->update_user_level_from_caps();
}
@@ -202,7 +203,7 @@ class WP_User {
if ( empty($this->roles[$role]) || (count($this->roles) <= 1) )
return;
unset($this->caps[$role]);
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
$this->get_role_caps();
}
@@ -215,42 +216,42 @@ class WP_User {
} else {
$this->roles = false;
}
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
$this->get_role_caps();
$this->update_user_level_from_caps();
}
function level_reduction($max, $item) {
- if(preg_match('/^level_(10|[0-9])$/i', $item, $matches)) {
- $level = intval($matches[1]);
- return max($max, $level);
- } else {
- return $max;
- }
+ if(preg_match('/^level_(10|[0-9])$/i', $item, $matches)) {
+ $level = intval($matches[1]);
+ return max($max, $level);
+ } else {
+ return $max;
+ }
}
function update_user_level_from_caps() {
- global $wpdb;
- $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
- update_usermeta($this->id, $wpdb->prefix.'user_level', $this->user_level);
+ global $wpdb;
+ $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
+ update_usermeta($this->ID, $wpdb->prefix.'user_level', $this->user_level);
}
function add_cap($cap, $grant = true) {
$this->caps[$cap] = $grant;
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
}
function remove_cap($cap) {
if ( empty($this->caps[$cap]) ) return;
unset($this->caps[$cap]);
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
}
function remove_all_caps() {
global $wpdb;
$this->caps = array();
- update_usermeta($this->id, $this->cap_key, '');
- update_usermeta($this->id, $wpdb->prefix.'user_level', '');
+ update_usermeta($this->ID, $this->cap_key, '');
+ update_usermeta($this->ID, $wpdb->prefix.'user_level', '');
$this->get_role_caps();
}
@@ -261,7 +262,7 @@ class WP_User {
$cap = $this->translate_level_to_cap($cap);
$args = array_slice(func_get_args(), 1);
- $args = array_merge(array($cap, $this->id), $args);
+ $args = array_merge(array($cap, $this->ID), $args);
$caps = call_user_func_array('map_meta_cap', $args);
// Must have ALL requested caps
$capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
@@ -298,7 +299,7 @@ function map_meta_cap($cap, $user_id) {
$post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('delete_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ return call_user_func_array('map_meta_cap', $args);
}
$post_author_data = get_userdata($post->post_author);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
@@ -352,7 +353,7 @@ function map_meta_cap($cap, $user_id) {
$post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('edit_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ return call_user_func_array('map_meta_cap', $args);
}
$post_author_data = get_userdata($post->post_author);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
@@ -402,7 +403,7 @@ function map_meta_cap($cap, $user_id) {
$post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('read_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ return call_user_func_array('map_meta_cap', $args);
}
if ( 'private' != $post->post_status ) {
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
index c15a4f8..3c7d10e 100644
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -187,8 +187,8 @@ function wp_dropdown_categories($args = '') {
$output .= "\t<option value='0'>$show_option_all</option>\n";
}
- if ( $show_option_none) {
- $show_option_none = apply_filters('list_cats', $show_option_none);
+ if ( $show_option_none) {
+ $show_option_none = apply_filters('list_cats', $show_option_none);
$output .= "\t<option value='-1'>$show_option_none</option>\n";
}
@@ -226,7 +226,7 @@ function wp_list_categories($args = '') {
extract($r);
$categories = get_categories($r);
-
+
$output = '';
if ( $title_li && 'list' == $style )
$output = '<li class="categories">' . $r['title_li'] . '<ul>';
@@ -249,7 +249,7 @@ function wp_list_categories($args = '') {
if ( $title_li && 'list' == $style )
$output .= '</ul></li>';
-
+
echo apply_filters('list_cats', $output);
}
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 1d3f6e4..7b3e7ca 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -30,6 +30,11 @@ function &get_categories($args = '') {
$r['number'] = (int) $r['number'];
extract($r);
+ $key = md5( serialize( $r ) );
+ if ( $cache = wp_cache_get( 'get_categories', 'category' ) )
+ if ( isset( $cache[ $key ] ) )
+ return $cache[ $key ];
+
$where = 'cat_ID > 0';
$inclusions = '';
if ( !empty($include) ) {
@@ -119,9 +124,20 @@ function &get_categories($args = '') {
}
reset ( $categories );
+ $cache[ $key ] = $categories;
+ wp_cache_set( 'get_categories', $cache, 'category' );
+
return apply_filters('get_categories', $categories, $r);
}
+function delete_get_categories_cache() {
+ wp_cache_delete('get_categories', 'category');
+}
+add_action( 'wp_insert_post', 'delete_get_categories_cache' );
+add_action( 'edit_category', 'delete_get_categories_cache' );
+add_action( 'add_category', 'delete_get_categories_cache' );
+add_action( 'delete_category', 'delete_get_categories_cache' );
+
// Retrieves category data given a category ID or category object.
// Handles category caching.
function &get_category(&$category, $output = OBJECT) {
@@ -232,19 +248,4 @@ function &_get_cat_children($category_id, $categories) {
return $category_list;
}
-function cat_is_ancestor_of($cat1, $cat2) {
- if ( is_int($cat1) )
- $cat1 = & get_category($cat1);
- if ( is_int($cat2) )
- $cat2 = & get_category($cat2);
-
- if ( !$cat1->cat_ID || !$cat2->category_parent )
- return false;
-
- if ( $cat2->category_parent == $cat1->cat_ID )
- return true;
-
- return cat_is_ancestor_of($cat1, get_category($cat2->parent_category));
-}
-
?>
diff --git a/wp-includes/classes.php b/wp-includes/classes.php
index aa19f3c..966e42e 100644
--- a/wp-includes/classes.php
+++ b/wp-includes/classes.php
@@ -1,7 +1,7 @@
<?php
class WP {
- var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
+ var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
var $extra_query_vars = array();
@@ -12,7 +12,7 @@ class WP {
var $matched_rule;
var $matched_query;
var $did_permalink = false;
-
+
function add_query_var($qv) {
$this->public_query_vars[] = $qv;
}
@@ -96,7 +96,7 @@ class WP {
preg_match("!^$match!", urldecode($request_match), $matches)) {
// Got a match.
$this->matched_rule = $match;
-
+
// Trim the query of everything up to the '?'.
$query = preg_replace("!^.+\?!", '', $query);
@@ -178,16 +178,26 @@ class WP {
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
} else {
// We're showing a feed, so WP is indeed the only thing that last changed
- if ( $this->query_vars['withcomments'] )
+ if ( $this->query_vars['withcomments']
+ || ( !$this->query_vars['withoutcomments']
+ && ( $this->query_vars['p']
+ || $this->query_vars['name']
+ || $this->query_vars['page_id']
+ || $this->query_vars['pagename']
+ || $this->query_vars['attachment']
+ || $this->query_vars['attachment_id']
+ )
+ )
+ )
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
- else
+ else
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
$wp_etag = '"' . md5($wp_last_modified) . '"';
@header("Last-Modified: $wp_last_modified");
@header("ETag: $wp_etag");
// Support for Conditional GET
- if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
$client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
else $client_etag = false;
@@ -249,8 +259,9 @@ class WP {
}
function query_posts() {
+ global $wp_the_query;
$this->build_query_string();
- query_posts($this->query_vars);
+ $wp_the_query->query($this->query_vars);
}
function handle_404() {
@@ -310,7 +321,7 @@ class WP_Error {
if ( empty($codes) )
return '';
- return $codes[0];
+ return $codes[0];
}
function get_error_messages($code = '') {
@@ -326,7 +337,7 @@ class WP_Error {
if ( isset($this->errors[$code]) )
return $this->errors[$code];
else
- return array();
+ return array();
}
function get_error_message($code = '') {
@@ -370,29 +381,29 @@ function is_wp_error($thing) {
// A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom
-class Walker {
+class Walker {
var $tree_type;
var $db_fields;
-
+
//abstract callbacks
function start_lvl($output) { return $output; }
function end_lvl($output) { return $output; }
function start_el($output) { return $output; }
function end_el($output) { return $output; }
-
+
function walk($elements, $to_depth) {
$args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = '';
-
+
//padding at the end
$last_element->post_parent = 0;
$last_element->post_id = 0;
$elements[] = $last_element;
-
+
$id_field = $this->db_fields['id'];
$parent_field = $this->db_fields['parent'];
-
+
$flat = ($to_depth == -1) ? true : false;
-
+
foreach ( $elements as $element ) {
// If flat, start and end the element and skip the level checks.
if ( $flat) {
@@ -432,7 +443,7 @@ class Walker {
$cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
}
-
+
while ( $parent = array_shift($parents) ) {
$depth--;
if ( !$to_depth || ($depth < $to_depth) ) {
@@ -452,7 +463,7 @@ class Walker {
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
}
}
-
+
// Start the element.
if ( !$to_depth || ($depth <= $to_depth) ) {
if ( $element->$id_field != 0 ) {
@@ -460,10 +471,10 @@ class Walker {
$output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
}
}
-
+
$previous_element = $element;
}
-
+
return $output;
}
}
@@ -471,19 +482,19 @@ class Walker {
class Walker_Page extends Walker {
var $tree_type = 'page';
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
-
+
function start_lvl($output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent<ul>\n";
return $output;
}
-
+
function end_lvl($output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
return $output;
}
-
+
function start_el($output, $page, $depth, $current_page, $show_date, $date_format) {
if ( $depth )
$indent = str_repeat("\t", $depth);
@@ -519,45 +530,45 @@ class Walker_PageDropdown extends Walker {
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
function start_el($output, $page, $depth, $args) {
- $pad = str_repeat('&nbsp;', $depth * 3);
+ $pad = str_repeat('&nbsp;', $depth * 3);
- $output .= "\t<option value=\"$page->ID\"";
- if ( $page->ID == $args['selected'] )
- $output .= ' selected="selected"';
- $output .= '>';
- $title = wp_specialchars($page->post_title);
- $output .= "$pad$title";
- $output .= "</option>\n";
+ $output .= "\t<option value=\"$page->ID\"";
+ if ( $page->ID == $args['selected'] )
+ $output .= ' selected="selected"';
+ $output .= '>';
+ $title = wp_specialchars($page->post_title);
+ $output .= "$pad$title";
+ $output .= "</option>\n";
- return $output;
+ return $output;
}
}
class Walker_Category extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
-
+
function start_lvl($output, $depth, $args) {
if ( 'list' != $args['style'] )
return $output;
-
+
$indent = str_repeat("\t", $depth);
$output .= "$indent<ul class='children'>\n";
return $output;
}
-
+
function end_lvl($output, $depth, $args) {
if ( 'list' != $args['style'] )
return $output;
-
+
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
return $output;
}
-
+
function start_el($output, $category, $depth, $args) {
extract($args);
-
+
$link = '<a href="' . get_category_link($category->cat_ID) . '" ';
if ( $use_desc_for_title == 0 || empty($category->category_description) )
$link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name, 1)) . '"';
@@ -565,24 +576,24 @@ class Walker_Category extends Walker {
$link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category),1) . '"';
$link .= '>';
$link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';
-
+
if ( (! empty($feed_image)) || (! empty($feed)) ) {
$link .= ' ';
-
+
if ( empty($feed_image) )
$link .= '(';
-
+
$link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
-
+
if ( !empty($feed) ) {
$title = ' title="' . $feed . '"';
$alt = ' alt="' . $feed . '"';
$name = $feed;
$link .= $title;
}
-
+
$link .= '>';
-
+
if ( !empty($feed_image) )
$link .= "<img src='$feed_image' $alt$title" . ' />';
else
@@ -607,14 +618,14 @@ class Walker_Category extends Walker {
} else {
$output .= "\t$link<br />\n";
}
-
+
return $output;
}
-
+
function end_el($output, $page, $depth, $args) {
if ( 'list' != $args['style'] )
return $output;
-
+
$output .= "</li>\n";
return $output;
}
@@ -624,10 +635,10 @@ class Walker_Category extends Walker {
class Walker_CategoryDropdown extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
-
- function start_el($output, $category, $depth, $args) {
+
+ function start_el($output, $category, $depth, $args) {
$pad = str_repeat('&nbsp;', $depth * 3);
-
+
$cat_name = apply_filters('list_cats', $category->cat_name, $category);
$output .= "\t<option value=\"".$category->cat_ID."\"";
if ( $category->cat_ID == $args['selected'] )
@@ -641,7 +652,7 @@ class Walker_CategoryDropdown extends Walker {
$output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp);
}
$output .= "</option>\n";
-
+
return $output;
}
}
@@ -688,7 +699,7 @@ class WP_Ajax_Response {
$action = $_POST['action'];
$x = '';
- $x .= "<response action='$action_$id'>"; // The action attribute in the xml output is formatted like a nonce action
+ $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action
$x .= "<$what id='$id'" . ( false !== $old_id ? "old_id='$old_id'>" : '>' );
$x .= $response;
$x .= $s;
diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index 8e8d457..3fee66a 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -93,7 +93,7 @@ function get_comment_date( $d = '' ) {
$date = mysql2date( get_option('date_format'), $comment->comment_date);
else
$date = mysql2date($d, $comment->comment_date);
- return apply_filters('get_comment_date', $date);
+ return apply_filters('get_comment_date', $date, $d);
}
function comment_date( $d = '' ) {
@@ -142,7 +142,7 @@ function get_comments_link() {
}
function comments_link( $file = '', $echo = true ) {
- echo get_comments_link();
+ echo get_comments_link();
}
function get_comments_number( $post_id = 0 ) {
@@ -161,17 +161,18 @@ function get_comments_number( $post_id = 0 ) {
return apply_filters('get_comments_number', $count);
}
-function comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $number = '' ) {
- global $id, $comment;
- $number = get_comments_number( $id );
- if ($number == 0) {
- $blah = $zero;
- } elseif ($number == 1) {
- $blah = $one;
- } elseif ($number > 1) {
- $blah = str_replace('%', $number, $more);
- }
- echo apply_filters('comments_number', $blah);
+function comments_number( $zero = false, $one = false, $more = false, $number = '' ) {
+ global $id;
+ $number = get_comments_number($id);
+
+ if ( $number > 1 )
+ $output = str_replace('%', $number, ( false === $more ) ? __('% Comments') : $more);
+ elseif ( $number == 0 )
+ $output = ( false === $zero ) ? __('No Comments') : $zero;
+ else // must be one
+ $output = ( false === $one ) ? __('1 Comment') : $one;
+
+ echo apply_filters('comments_number', $output, $number);
}
function get_comment_text() {
@@ -190,7 +191,7 @@ function get_comment_time( $d = '', $gmt = false ) {
$date = mysql2date(get_option('time_format'), $comment_date);
else
$date = mysql2date($d, $comment_date);
- return apply_filters('get_comment_time', $date);
+ return apply_filters('get_comment_time', $date, $d, $gmt);
}
function comment_time( $d = '' ) {
@@ -239,9 +240,9 @@ function trackback_url( $display = true ) {
function trackback_rdf($timezone = 0) {
global $id;
if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
- 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/">
+ echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description rdf:about="';
the_permalink();
echo '"'."\n";
@@ -264,7 +265,7 @@ function comments_open() {
function pings_open() {
global $post;
- if ( 'open' == $post->ping_status )
+ if ( 'open' == $post->ping_status )
return true;
else
return false;
@@ -298,7 +299,7 @@ function comments_template( $file = '/comments.php' ) {
}
function comments_popup_script($width=400, $height=400, $file='') {
- global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
+ global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
if (empty ($file)) {
$wpcommentspopupfile = ''; // Use the index.
@@ -306,9 +307,9 @@ function comments_popup_script($width=400, $height=400, $file='') {
$wpcommentspopupfile = $file;
}
- $wpcommentsjavascript = 1;
- $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
- echo $javascript;
+ $wpcommentsjavascript = 1;
+ $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
+ echo $javascript;
}
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index 5d991e2..557c46b 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -18,11 +18,11 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
// Skip empty lines
if (empty($word)) { continue; }
- // Do some escaping magic so that '#' chars in the
+ // Do some escaping magic so that '#' chars in the
// spam words don't break things:
$word = preg_quote($word, '#');
- $pattern = "#$word#i";
+ $pattern = "#$word#i";
if ( preg_match($pattern, $author) ) return false;
if ( preg_match($pattern, $email) ) return false;
if ( preg_match($pattern, $url) ) return false;
@@ -103,9 +103,9 @@ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = fals
if ($no_cache) {
$query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'";
if (false == $include_unapproved) {
- $query .= " AND comment_approved = '1'";
+ $query .= " AND comment_approved = '1'";
}
- $myrow = $wpdb->get_row($query, ARRAY_A);
+ $myrow = $wpdb->get_row($query, ARRAY_A);
} else {
$myrow['comment_ID'] = $postc->comment_ID;
$myrow['comment_post_ID'] = $postc->comment_post_ID;
@@ -157,7 +157,7 @@ function sanitize_comment_cookies() {
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
$comment_author_email = stripslashes($comment_author_email);
- $comment_author_email = wp_specialchars($comment_author_email, true);
+ $comment_author_email = wp_specialchars($comment_author_email, true);
$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
}
@@ -243,11 +243,11 @@ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_age
// Skip empty lines
if ( empty($word) ) { continue; }
- // Do some escaping magic so that '#' chars in the
+ // Do some escaping magic so that '#' chars in the
// spam words don't break things:
$word = preg_quote($word, '#');
- $pattern = "#$word#i";
+ $pattern = "#$word#i";
if ( preg_match($pattern, $author ) ) return true;
if ( preg_match($pattern, $email ) ) return true;
if ( preg_match($pattern, $url ) ) return true;
@@ -328,9 +328,9 @@ function wp_insert_comment($commentdata) {
if ( ! isset($user_id) )
$user_id = 0;
- $result = $wpdb->query("INSERT INTO $wpdb->comments
+ $result = $wpdb->query("INSERT INTO $wpdb->comments
(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id)
- VALUES
+ VALUES
('$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id')
");
@@ -397,26 +397,26 @@ function wp_new_comment( $commentdata ) {
}
function wp_set_comment_status($comment_id, $comment_status) {
- global $wpdb;
+ global $wpdb;
- switch($comment_status) {
+ switch($comment_status) {
case 'hold':
$query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
break;
case 'approve':
$query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
break;
- case 'spam':
- $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";
- break;
+ case 'spam':
+ $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
case 'delete':
return wp_delete_comment($comment_id);
break;
default:
return false;
- }
-
- if ($wpdb->query($query)) {
+ }
+
+ if ($wpdb->query($query)) {
do_action('wp_set_comment_status', $comment_id, $comment_status);
$comment = get_comment($comment_id);
@@ -425,9 +425,9 @@ function wp_set_comment_status($comment_id, $comment_status) {
if( is_object( $c ) )
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
return true;
- } else {
+ } else {
return false;
- }
+ }
}
function wp_update_comment($commentarr) {
@@ -582,7 +582,7 @@ function do_all_pings() {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
pingback($ping->post_content, $ping->ID);
}
-
+
// Do Enclosures
while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
@@ -705,7 +705,7 @@ function pingback($content, $post_ID) {
$pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
if ($pingback_server_url) {
- @ set_time_limit( 60 );
+ @ set_time_limit( 60 );
// Now, the RPC call
debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
debug_fwrite($log, 'Page Linked From: ');
diff --git a/wp-includes/compat.php b/wp-includes/compat.php
index 3b64dfb..997307f 100644
--- a/wp-includes/compat.php
+++ b/wp-includes/compat.php
@@ -36,13 +36,13 @@ if (!function_exists('ob_clean')) {
/* Added in PHP 4.3.0 */
function printr($var, $do_not_echo = false) {
- // from php.net/print_r user contributed notes
+ // from php.net/print_r user contributed notes
ob_start();
print_r($var);
$code = htmlentities(ob_get_contents());
ob_clean();
if (!$do_not_echo) {
- echo "<pre>$code</pre>";
+ echo "<pre>$code</pre>";
}
ob_end_clean();
return $code;
@@ -57,11 +57,11 @@ if ( !function_exists('file_get_contents') ) {
}
if (!defined('CASE_LOWER')) {
- define('CASE_LOWER', 0);
+ define('CASE_LOWER', 0);
}
if (!defined('CASE_UPPER')) {
- define('CASE_UPPER', 1);
+ define('CASE_UPPER', 1);
}
@@ -73,43 +73,43 @@ 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: 3901 $
+ * @version $Revision: 4495 $
* @since PHP 4.2.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('array_change_key_case')) {
- function array_change_key_case($input, $case = CASE_LOWER)
- {
- if (!is_array($input)) {
- user_error('array_change_key_case(): The argument should be an array',
- E_USER_WARNING);
- return false;
- }
-
- $output = array ();
- $keys = array_keys($input);
- $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
-
- foreach ($keys as $key) {
- $output[$casefunc($key)] = $input[$key];
- }
-
- return $output;
- }
+ function array_change_key_case($input, $case = CASE_LOWER)
+ {
+ if (!is_array($input)) {
+ user_error('array_change_key_case(): The argument should be an array',
+ E_USER_WARNING);
+ return false;
+ }
+
+ $output = array ();
+ $keys = array_keys($input);
+ $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
+
+ foreach ($keys as $key) {
+ $output[$casefunc($key)] = $input[$key];
+ }
+
+ return $output;
+ }
}
// From php.net
if(!function_exists('http_build_query')) {
- function http_build_query( $formdata, $numeric_prefix = null, $key = null ) {
- $res = array();
- foreach ((array)$formdata as $k=>$v) {
- $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k);
- if ($key) $tmp_key = $key.'['.$tmp_key.']';
- $res[] = ( ( is_array($v) || is_object($v) ) ? http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) );
- }
- $separator = ini_get('arg_separator.output');
- return implode($separator, $res);
- }
+ function http_build_query( $formdata, $numeric_prefix = null, $key = null ) {
+ $res = array();
+ foreach ((array)$formdata as $k=>$v) {
+ $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k);
+ if ($key) $tmp_key = $key.'['.$tmp_key.']';
+ $res[] = ( ( is_array($v) || is_object($v) ) ? http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) );
+ }
+ $separator = ini_get('arg_separator.output');
+ return implode($separator, $res);
+ }
}
if ( !function_exists('_') ) {
diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php
index b75e07a..38b07ca 100644
--- a/wp-includes/deprecated.php
+++ b/wp-includes/deprecated.php
@@ -129,8 +129,8 @@ function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
$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) ) {
+ || ($author_data->user_level > $post_author_data->user_level)
+ || ($author_data->user_level >= 10) ) {
return true;
} else {
return false;
@@ -199,19 +199,19 @@ function user_can_edit_user($user_id, $other_user) {
** 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);
+ $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()
@@ -252,16 +252,16 @@ function wp_get_linksbyname($category, $args = '') {
**/
// 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);
+ 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()
@@ -301,40 +301,40 @@ function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit
**/
// 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;
+ 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()
@@ -359,12 +359,12 @@ function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
** 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) {
+ $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);
+ get_linksbyname($cat_name, $before, $after, $between, $show_images,
+ $orderby, $show_description, true, $limit, $show_updated);
}
/** function get_links_withrating()
@@ -389,12 +389,12 @@ function get_linksbyname_withrating($cat_name = "noname", $before = '',
** 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) {
+ $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);
+ get_links($category, $before, $after, $between, $show_images, $orderby,
+ $show_description, true, $limit, $show_updated);
}
/** function get_get_autotoggle()
@@ -403,7 +403,7 @@ function get_links_withrating($category = -1, $before = '', $after = '<br />',
** uses 0
*/
function get_autotoggle($id = 0) {
- return 0;
+ return 0;
}
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) {
@@ -433,7 +433,7 @@ function wp_list_cats($args = '') {
$r['style'] = 'break';
$r['title_li'] = '';
- return wp_list_categories($r);
+ return wp_list_categories($r);
}
function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
diff --git a/wp-includes/feed.php b/wp-includes/feed.php
index ec11d65..deebbea 100644
--- a/wp-includes/feed.php
+++ b/wp-includes/feed.php
@@ -135,9 +135,9 @@ function get_the_category_rss($type = 'rss') {
foreach ( (array) $categories as $category ) {
$category->cat_name = convert_chars($category->cat_name);
if ( 'rdf' == $type )
- $the_list .= "\n\t\t<dc:subject>$category->cat_name</dc:subject>\n";
+ $the_list .= "\n\t\t<dc:subject><![CDATA[$category->cat_name]]></dc:subject>\n";
else
- $the_list .= "\n\t\t<category>$category->cat_name</category>\n";
+ $the_list .= "\n\t\t<category><![CDATA[$category->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 7d083a8..14b100a 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -2,56 +2,47 @@
function wptexturize($text) {
global $wp_cockneyreplace;
+ $next = true;
$output = '';
- // Capture tags and everything inside them
- $textarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
- $stop = count($textarr); $next = true; // loop stuff
- for ($i = 0; $i < $stop; $i++) {
- $curl = $textarr[$i];
+ $curl = '';
+ $textarr = preg_split('/(<.*>)/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $stop = count($textarr);
+
+ // if a plugin has provided an autocorrect array, use it
+ if ( isset($wp_cockneyreplace) ) {
+ $cockney = array_keys($wp_cockneyreplace);
+ $cockney_replace = array_values($wp_cockneyreplace);
+ } else {
+ $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
+ $cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
+ }
- if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
- $curl = str_replace('---', '&#8212;', $curl);
- $curl = str_replace(' -- ', ' &#8212; ', $curl);
- $curl = str_replace('--', '&#8211;', $curl);
- $curl = str_replace('xn&#8211;', 'xn--', $curl);
- $curl = str_replace('...', '&#8230;', $curl);
- $curl = str_replace('``', '&#8220;', $curl);
-
- // if a plugin has provided an autocorrect array, use it
- if ( isset($wp_cockneyreplace) ) {
- $cockney = array_keys($wp_cockneyreplace);
- $cockney_replace = array_values($wp_cockneyreplace);
- } else {
- $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
- $cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
- }
+ $static_characters = array_merge(array('---', ' -- ', '--', 'xn&#8211;', '...', '``', '\'s', '\'\'', ' (tm)'), $cockney);
+ $static_replacements = array_merge(array('&#8212;', ' &#8212; ', '&#8211;', 'xn--', '&#8230;', '&#8220;', '&#8217;s', '&#8221;', ' &#8482;'), $cockneyreplace);
- $curl = str_replace($cockney, $cockneyreplace, $curl);
+ $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/');
+ $dynamic_replacements = array('&#8217;$1','$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1&#8220;$2', '&#8221;$1', '&#8217;$1', '$1&#215;$2');
- $curl = preg_replace("/'s/", '&#8217;s', $curl);
- $curl = preg_replace("/'(\d\d(?:&#8217;|')?s)/", "&#8217;$1", $curl);
- $curl = preg_replace('/(\s|\A|")\'/', '$1&#8216;', $curl);
- $curl = preg_replace('/(\d+)"/', '$1&#8243;', $curl);
- $curl = preg_replace("/(\d+)'/", '$1&#8242;', $curl);
- $curl = preg_replace("/(\S)'([^'\s])/", "$1&#8217;$2", $curl);
- $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1&#8220;$2', $curl);
- $curl = preg_replace('/"(\s|\S|\Z)/', '&#8221;$1', $curl);
- $curl = preg_replace("/'([\s.]|\Z)/", '&#8217;$1', $curl);
- $curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl);
- $curl = str_replace("''", '&#8221;', $curl);
+ for ( $i = 0; $i < $stop; $i++ ) {
+ $curl = $textarr[$i];
- $curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $curl);
+ if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
+ // static strings
+ $curl = str_replace($static_characters, $static_replacements, $curl);
+ // regular expressions
+ $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
} elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
- // strstr is fast
$next = false;
} else {
$next = true;
}
+
$curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$1', $curl);
$output .= $curl;
}
- return $output;
+
+ return $output;
}
function clean_pre($text) {
@@ -65,18 +56,18 @@ function wpautop($pee, $br = 1) {
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
// Space things out a little
- $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
+ $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
$pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$1\n\n", $pee);
- $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
+ $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
- $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
- $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
+ $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
+ $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee);
- $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
+ $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
if ($br) {
$pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee);
$pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
@@ -86,7 +77,7 @@ function wpautop($pee, $br = 1) {
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
- return $pee;
+ return $pee;
}
@@ -109,7 +100,9 @@ function seems_utf8($Str) { # by bmorel at ssi dot fr
function wp_specialchars( $text, $quotes = 0 ) {
// Like htmlspecialchars except don't double-encode HTML entities
- $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&#038;$1', $text);
+ $text = str_replace('&&', '&#038;&', $text);
+ $text = str_replace('&&', '&#038;&', $text);
+ $text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&#038;$1', $text);
$text = str_replace('<', '&lt;', $text);
$text = str_replace('>', '&gt;', $text);
if ( 'double' === $quotes ) {
@@ -124,35 +117,35 @@ function wp_specialchars( $text, $quotes = 0 ) {
}
function utf8_uri_encode( $utf8_string ) {
- $unicode = '';
- $values = array();
- $num_octets = 1;
-
- for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {
-
- $value = ord( $utf8_string[ $i ] );
-
- if ( $value < 128 ) {
- $unicode .= chr($value);
- } else {
- if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
-
- $values[] = $value;
-
- if ( count( $values ) == $num_octets ) {
+ $unicode = '';
+ $values = array();
+ $num_octets = 1;
+
+ for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {
+
+ $value = ord( $utf8_string[ $i ] );
+
+ if ( $value < 128 ) {
+ $unicode .= chr($value);
+ } else {
+ if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
+
+ $values[] = $value;
+
+ if ( count( $values ) == $num_octets ) {
if ($num_octets == 3) {
- $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
+ $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
} else {
- $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
+ $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
}
$values = array();
$num_octets = 1;
- }
- }
- }
+ }
+ }
+ }
- return $unicode;
+ return $unicode;
}
function remove_accents($string) {
@@ -348,7 +341,7 @@ function sanitize_title_with_dashes($title) {
return $title;
}
-function convert_chars($content, $flag = 'obsolete') {
+function convert_chars($content, $flag = 'obsolete') {
// Translation of invalid Unicode references range to valid range
$wp_htmltranswinuni = array(
'&#128;' => '&#8364;', // the Euro sign
@@ -414,22 +407,22 @@ function funky_javascript_fix($text) {
/*
balanceTags
-
+
Balances Tags of string using a modified stack.
-
+
@param text Text to be balanced
@return Returns balanced text
@author Leonard Lin (leonard@acm.org)
@version v1.1
@date November 4, 2001
@license GPL v2.0
- @notes
- @changelog
+ @notes
+ @changelog
--- Modified by Scott Reilly (coffee2code) 02 Aug 2004
- 1.2 ***TODO*** Make better - change loop condition to $text
- 1.1 Fixed handling of append/stack pop order of end text
- Added Cleaning Hooks
- 1.0 First Version
+ 1.2 ***TODO*** Make better - change loop condition to $text
+ 1.1 Fixed handling of append/stack pop order of end text
+ Added Cleaning Hooks
+ 1.0 First Version
*/
function balanceTags($text, $is_comment = 0, $force = false) {
@@ -455,7 +448,7 @@ function balanceTags($text, $is_comment = 0, $force = false) {
if ($regex[1][0] == "/") { // End Tag
$tag = strtolower(substr($regex[1],1));
// if too many closing tags
- if($stacksize <= 0) {
+ if($stacksize <= 0) {
$tag = '';
//or close to be safe $tag = '/' . $tag;
}
@@ -512,7 +505,7 @@ function balanceTags($text, $is_comment = 0, $force = false) {
}
$newtext .= substr($text,0,$i) . $tag;
$text = substr($text,$i+$l);
- }
+ }
// Clear Tag Queue
$newtext .= $tagqueue;
@@ -561,10 +554,10 @@ function backslashit($string) {
}
function trailingslashit($string) {
- if ( '/' != substr($string, -1)) {
- $string .= '/';
- }
- return $string;
+ if ( '/' != substr($string, -1)) {
+ $string .= '/';
+ }
+ return $string;
}
function addslashes_gpc($gpc) {
@@ -580,11 +573,11 @@ function addslashes_gpc($gpc) {
function stripslashes_deep($value)
{
- $value = is_array($value) ?
- array_map('stripslashes_deep', $value) :
- stripslashes($value);
+ $value = is_array($value) ?
+ array_map('stripslashes_deep', $value) :
+ stripslashes($value);
- return $value;
+ return $value;
}
function antispambot($emailaddy, $mailto=0) {
@@ -740,7 +733,7 @@ function sanitize_email($email) {
return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);
}
-function human_time_diff( $from, $to = '' ) {
+function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
@@ -754,7 +747,7 @@ function human_time_diff( $from, $to = '' ) {
$hours = round($diff / 3600);
if ($hours <= 1)
$since = __('1 hour');
- else
+ else
$since = sprintf( __('%s hours'), $hours );
} elseif ($diff >= 86400) {
$days = round($diff / 86400);
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index e87724a..f6ba499 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -12,7 +12,7 @@ function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
if( 'U' == $dateformatstring )
return $i;
-
+
if ( -1 == $i || false == $i )
$i = 0;
@@ -479,7 +479,7 @@ function wp_get_http_headers( $url, $red = 1 ) {
@set_time_limit( 60 );
if ( $red > 5 )
- return false;
+ return false;
$parts = parse_url( $url );
$file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
@@ -508,9 +508,9 @@ function wp_get_http_headers( $url, $red = 1 ) {
preg_match('/.*([0-9]{3}).*/', $response, $return);
$headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
- $code = $headers['response'];
- if ( ('302' == $code || '301' == $code) && isset($headers['location']) )
- return wp_get_http_headers( $headers['location'], ++$red );
+ $code = $headers['response'];
+ if ( ('302' == $code || '301' == $code) && isset($headers['location']) )
+ return wp_get_http_headers( $headers['location'], ++$red );
return $headers;
}
@@ -573,9 +573,22 @@ function update_post_category_cache($post_ids) {
return;
if ( is_array($post_ids) )
- $post_ids = implode(',', $post_ids);
+ $post_id_list = implode(',', $post_ids);
+
+ $post_id_array = (array) explode(',', $post_ids);
+ $count = count( $post_id_array);
+ for ( $i = 0; $i < $count; $i++ ) {
+ $post_id = $post_id_array[ $i ];
+ if ( isset( $category_cache[$blog_id][$post_id] ) ) {
+ unset( $post_id_array[ $i ] );
+ continue;
+ }
+ }
+ if ( count( $post_id_array ) == 0 )
+ return;
+ $post_id_list = join( ',', $post_id_array ); // with already cached stuff removed
- $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
+ $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
if ( empty($dogs) )
return;
@@ -611,11 +624,24 @@ function update_postmeta_cache($post_id_list = '') {
// We should validate this comma-separated list for the upcoming SQL query
$post_id_list = preg_replace('|[^0-9,]|', '', $post_id_list);
+ if ( empty( $post_id_list ) )
+ return false;
+
// we're marking each post as having its meta cached (with no keys... empty array), to prevent posts with no meta keys from being queried again
// any posts that DO have keys will have this empty array overwritten with a proper array, down below
- $post_id_array = explode(',', $post_id_list);
- foreach ( (array) $post_id_array as $pid )
- $post_meta_cache[$blogi_id][$pid] = array();
+ $post_id_array = (array) explode(',', $post_id_list);
+ $count = count( $post_id_array);
+ for ( $i = 0; $i < $count; $i++ ) {
+ $post_id = $post_id_array[ $i ];
+ if ( isset( $post_meta_cache[$blog_id][$post_id] ) ) { // If the meta is already cached
+ unset( $post_id_array[ $i ] );
+ continue;
+ }
+ $post_meta_cache[$blog_id][$post_id] = array();
+ }
+ if ( count( $post_id_array ) == 0 )
+ return;
+ $post_id_list = join( ',', $post_id_array ); // with already cached stuff removeds
// Get post-meta info
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
@@ -755,7 +781,7 @@ function add_magic_quotes($array) {
function wp_remote_fopen( $uri ) {
if ( ini_get('allow_url_fopen') ) {
- $fp = fopen( $uri, 'r' );
+ $fp = @fopen( $uri, 'r' );
if ( !$fp )
return false;
$linea = '';
@@ -797,9 +823,9 @@ function status_header( $header ) {
$text = 'Gone';
if ( substr(php_sapi_name(), 0, 3) == 'cgi' )
- @header("Status: $header $text");
- else
@header("HTTP/1.1 $header $text");
+ else
+ @header("Status: $header $text");
}
function nocache_headers() {
@@ -822,8 +848,8 @@ function get_num_queries() {
}
function bool_from_yn($yn) {
- if ($yn == 'Y') return 1;
- return 0;
+ if ($yn == 'Y') return 1;
+ return 0;
}
function do_feed() {
@@ -836,7 +862,7 @@ function do_feed() {
$feed = 'rss2';
$for_comments = false;
- if ( is_singular() || get_query_var('withcomments') == 1 || $feed == 'comments-rss2' ) {
+ if ( 1 != get_query_var('withoutcomments') && ( is_singular() || get_query_var('withcomments') == 1 || $feed == 'comments-rss2' ) ) {
$feed = 'rss2';
$for_comments = true;
}
@@ -980,7 +1006,7 @@ function wp_upload_dir() {
return array('error' => $message);
}
- $uploads = array('path' => $dir, 'url' => $url, 'error' => false);
+ $uploads = array('path' => $dir, 'url' => $url, 'error' => false);
return apply_filters('upload_dir', $uploads);
}
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index 4849360..017cedb 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -426,6 +426,15 @@ function calendar_week_mod($num) {
function get_calendar($initial = true) {
global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts;
+ $key = md5( $m . $monthnum . $year );
+ if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
+ if ( isset( $cache[ $key ] ) ) {
+ echo $cache[ $key ];
+ return;
+ }
+ }
+
+ ob_start();
// Quick check. If we have no posts at all, abort!
if ( !$posts ) {
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
@@ -475,7 +484,7 @@ function get_calendar($initial = true) {
FROM $wpdb->posts
WHERE post_date > '$thisyear-$thismonth-01'
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
- AND post_type = 'post' AND post_status = 'publish'
+ AND post_type = 'post' AND post_status = 'publish'
ORDER BY post_date ASC
LIMIT 1");
@@ -599,7 +608,22 @@ function get_calendar($initial = true) {
echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
echo "\n\t</tr>\n\t</tbody>\n\t</table>";
+
+ $output = ob_get_contents();
+ ob_end_clean();
+ echo $output;
+ $cache[ $key ] = $output;
+ wp_cache_set( 'get_calendar', $cache, 'calendar' );
+}
+
+function delete_get_calendar_cache() {
+ wp_cache_delete( 'get_calendar', 'calendar' );
}
+add_action( 'save_post', 'delete_get_calendar_cache' );
+add_action( 'delete_post', 'delete_get_calendar_cache' );
+add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
+add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
+add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
function allowed_tags() {
@@ -763,30 +787,12 @@ function rich_edit_exists() {
}
function user_can_richedit() {
- $can = true;
+ global $wp_rich_edit;
+
+ if ( !isset($wp_rich_edit) )
+ $wp_rich_edit = ( 'true' == get_user_option('rich_editing') && !preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) && rich_edit_exists() ) ? true : false;
- if ( 'true' != get_user_option('rich_editing') || preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
- $can = false;
-
- return apply_filters('user_can_richedit', $can);
-}
-
-function user_can_switchedit() {
- $can = true;
-
- $ua = $_SERVER['HTTP_USER_AGENT'];
-
- if (
- !user_can_richedit() ||
- ( // Mozilla Test
- strstr($ua, 'Mozilla/5.0') &&
- !strstr($ua, 'ompatible') &&
- !strstr($ua, 'irefox')
- )
- )
- $can = false;
-
- return apply_filters('user_can_switchedit', $can);
+ return apply_filters('user_can_richedit', $wp_rich_edit);
}
function the_editor($content, $id = 'content', $prev_id = 'title') {
@@ -799,19 +805,24 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
if ( user_can_richedit() ) :
add_filter('the_editor_content', 'wp_richedit_pre');
- if ( user_can_switchedit() ) :
+ // The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it.
?>
+ <style type="text/css">
+ #postdivrich table, #postdivrich #quicktags {border-top: none;}
+ #quicktags {border-bottom: none; padding-bottom: 2px; margin-bottom: -1px;}
+ #edButtons {border-bottom: 1px solid #ccc;}
+ </style>
<div id='edButtons' style='display:none;'>
<div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div>
- <input id='edButtonPreview' class='edButtonFore' type='button' value='<?php _e('Editor'); ?>' />
- <input id='edButtonHTML' class='edButtonBack' type='button' value='<?php _e('HTML'); ?>' onclick='switchEditors("<?php echo $id; ?>")' />
+ <input id='edButtonPreview' class='edButtonFore' type='button' value='<?php _e('Visual'); ?>' />
+ <input id='edButtonHTML' class='edButtonBack' type='button' value='<?php _e('Code'); ?>' onclick='switchEditors("<?php echo $id; ?>")' />
</div>
<script type="text/javascript">
if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 )
document.getElementById('edButtons').style.display = 'block';
</script>
- <?php endif; endif; ?>
+ <?php endif; ?>
<div id="quicktags">
<?php wp_print_scripts( 'quicktags' ); ?>
<script type="text/javascript">edToolbar()</script>
@@ -846,9 +857,7 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
</script>
<?php
- $class = user_can_switchedit() ? 'switched' : 'unswitched';
-
- $the_editor = apply_filters('the_editor', "<div class='$class'><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
+ $the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
$the_editor_content = apply_filters('the_editor_content', $content);
printf($the_editor, $the_editor_content);
diff --git a/wp-includes/js/autosave.js.php b/wp-includes/js/autosave.js.php
index c360318..2e76230 100644
--- a/wp-includes/js/autosave.js.php
+++ b/wp-includes/js/autosave.js.php
@@ -3,10 +3,20 @@ cache_javascript_headers();
?>
var autosaveLast = '';
var autosavePeriodical;
+
function autosave_start_timer() {
var form = $('post');
autosaveLast = form.post_title.value+form.content.value;
- autosavePeriodical = new PeriodicalExecuter(autosave, <?php echo apply_filters('autosave_interval', '60'); ?>);
+ autosavePeriodical = new PeriodicalExecuter(autosave, <?php echo apply_filters('autosave_interval', '120'); ?>);
+ //Disable autosave after the form has been submitted
+ if(form.addEventListener) {
+ form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false);
+ }
+ if(form.attachEvent) {
+ $('save').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
+ $('publish').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
+ $('deletepost').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
+ }
}
addLoadEvent(autosave_start_timer)
diff --git a/wp-includes/js/list-manipulation-js.php b/wp-includes/js/list-manipulation-js.php
index 6c89d5f..112d19f 100644
--- a/wp-includes/js/list-manipulation-js.php
+++ b/wp-includes/js/list-manipulation-js.php
@@ -1,8 +1,4 @@
-<?php
-@require_once('../../wp-config.php');
-cache_javascript_headers();
-$handler = get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php';
-?>
+<?php @require_once('../../wp-config.php'); cache_javascript_headers(); ?>
addLoadEvent(function(){theList=new listMan();});
function deleteSomething(what,id,message,obj){if(!obj)obj=theList;if(!message)message="<?php printf(__('Are you sure you want to delete this %s?'),"'+what+'"); ?>";if(confirm(message))return obj.ajaxDelete(what,id);else return false;}
function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxDimmer(what,id,dimClass);}
@@ -10,7 +6,7 @@ function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxD
var listMan = Class.create();
Object.extend(listMan.prototype, {
ajaxRespEl: 'ajax-response',
- ajaxHandler: '<?php echo $handler; ?>',
+ ajaxHandler: false,
inputData: '',
clearInputs: [],
showLink: true,
@@ -51,16 +47,18 @@ Object.extend(listMan.prototype, {
if ( tempObj.showLink )
tempObj.showLink = id;
});
+ ajaxAdd.myResponseElement.update(tempObj.showLink ? ( "<div id='jumplink' class='updated fade'><p><a href='#" + what + '-' + tempObj.showLink + "'><?php _e('Jump to new item'); ?></a></p></div>" ) : '');
}
- ajaxAdd.myResponseElement.update(tempObj.showLink ? ( "<div id='jumplink' class='updated fade'><p><a href='#" + what + '-' + tempObj.showLink + "'><?php _e('Jump to new item'); ?></a></p></div>" ) : '');
if ( tempObj.addComplete && typeof tempObj.addComplete == 'function' )
tempObj.addComplete( what, where, update, transport );
tempObj.recolorList();
ajaxAdd.restoreInputs = null;
});
- ajaxAdd.addOnWPError( function(transport) { tempObj.restoreForm(ajaxAdd.restoreInputs); });
+ if ( !update )
+ ajaxAdd.addOnWPError( function(transport) { tempObj.restoreForm(ajaxAdd.restoreInputs); });
ajaxAdd.request(ajaxAdd.url);
- this.clear();
+ if ( !update )
+ this.clear();
return false;
},
@@ -262,7 +260,5 @@ function killSubmit ( code, e ) {
}
}
}
-//Pretty func adapted from ALA http://www.alistapart.com/articles/gettingstartedwithajax
-function getNodeValue(tree,el){try { var r = tree.getElementsByTagName(el)[0].firstChild.nodeValue; } catch(err) { var r = null; } return r; }
//Generic but lame JS closure
function encloseFunc(f){var a=arguments[1];return function(){return f(a);}}
diff --git a/wp-includes/js/tinymce/license.txt b/wp-includes/js/tinymce/license.txt
index 3b0396a..60d6d4c 100644
--- a/wp-includes/js/tinymce/license.txt
+++ b/wp-includes/js/tinymce/license.txt
@@ -1,13 +1,14 @@
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
- Copyright (C) 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
Preamble
@@ -16,97 +17,109 @@ freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-.
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-.
- GNU LIBRARY GENERAL PUBLIC LICENSE
+ GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
@@ -145,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
-.
+
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@@ -203,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
-.
+
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@@ -254,8 +267,8 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
-.
- 6. As an exception to the Sections above, you may also compile or
+
+ 6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
@@ -282,23 +295,31 @@ of these things:
Library will not necessarily be able to recompile the application
to use the modified definitions.)
- b) Accompany the work with a written offer, valid for at
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
- c) If distribution of the work is made by offering access to copy
+ d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
- d) Verify that the user has already received a copy of these
+ e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
@@ -308,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
-.
+
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@@ -347,9 +368,9 @@ Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
+You are not responsible for enforcing compliance by third parties with
this License.
-.
+
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@@ -390,7 +411,7 @@ excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
+versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
@@ -401,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
-.
+
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@@ -435,3 +456,49 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
index 4b88d2e..68563f9 100644
--- a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
@@ -1,20 +1,18 @@
/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.11 $
- * $Date: 2006/03/22 12:21:21 $
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('autosave', 'en,tr,sv,cs,he,nb,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,pl,pt_br');
+tinyMCE.importPluginLanguagePack('autosave');
var TinyMCE_AutoSavePlugin = {
getInfo : function() {
return {
longname : 'Auto save',
- author : 'Moxiecode Systems',
+ author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
diff --git a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
index ad0fa87..c8a6295 100644
--- a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
@@ -1,20 +1,18 @@
/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.16 $
- * $Date: 2006/02/10 21:34:28 $
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('directionality', 'en,tr,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');
+tinyMCE.importPluginLanguagePack('directionality');
var TinyMCE_DirectionalityPlugin = {
getInfo : function() {
return {
longname : 'Directionality',
- author : 'Moxiecode Systems',
+ author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
index 74d1805..c005a9e 100644
--- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.8 $
- * $Date: 2006/02/06 20:02:38 $
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
*
* Moxiecode DHTML Windows script.
*
@@ -15,7 +13,7 @@ var TinyMCE_InlinePopupsPlugin = {
getInfo : function() {
return {
longname : 'Inline Popups',
- author : 'Moxiecode Systems',
+ author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
@@ -436,7 +434,7 @@ TinyMCE_Windows.prototype.onLoad = function(name) {
TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
var iframe = document.createElement("iframe");
- var div = document.createElement("div");
+ var div = document.createElement("div"), doc;
width = parseInt(width);
height = parseInt(height)+1;
@@ -488,7 +486,7 @@ TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top,
if (this.isSafari) {
// Give Safari some time to setup
window.setTimeout(function() {
- doc = window.frames[id_prefix + '_iframe'].document;
+ var doc = window.frames[id_prefix + '_iframe'].document;
doc.open();
doc.write(html);
doc.close();
diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js b/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
index a88ffd7..325d293 100644
--- a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
+++ b/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: mcwindows.js,v $
- * $Revision: 1.2 $
- * $Date: 2005/10/18 13:59:43 $
+ * $Id: mcwindows.js 18 2006-06-29 14:11:23Z spocke $
*
* Moxiecode DHTML Windows script.
*
diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
index d9bd215..de5edbe 100644
--- a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
@@ -1 +1,386 @@
-tinyMCE.importPluginLanguagePack('paste','en,tr,sv,cs,zh_cn,fr_ca,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_PastePlugin={getInfo:function(){return{longname:'Paste text/word',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},initInstance:function(inst){if(tinyMCE.isMSIE&&tinyMCE.getParam("paste_auto_cleanup_on_paste",false))tinyMCE.addEvent(inst.getBody(),"paste",TinyMCE_PastePlugin._handlePasteEvent);},getControlHTML:function(cn){switch(cn){case"pastetext":return tinyMCE.getButtonHTML(cn,'lang_paste_text_desc','{$pluginurl}/images/pastetext.gif','mcePasteText',true);case"pasteword":return tinyMCE.getButtonHTML(cn,'lang_paste_word_desc','{$pluginurl}/images/pasteword.gif','mcePasteWord',true);case"selectall":return tinyMCE.getButtonHTML(cn,'lang_selectall_desc','{$pluginurl}/images/selectall.gif','mceSelectAll',true);}return'';},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mcePasteText":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false))TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"),true);else{var template=new Array();template['file']='../../plugins/paste/pastetext.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertText(value['html'],value['linebreaks']);return true;case"mcePasteWord":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false)){var html=TinyMCE_PastePlugin._clipboardHTML();if(html&&html.length>0)TinyMCE_PastePlugin._insertWordContent(html);}else{var template=new Array();template['file']='../../plugins/paste/pasteword.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertWordContent(value);return true;case"mceSelectAll":tinyMCE.execInstanceCommand(editor_id,'selectall');return true;}return false;},_handlePasteEvent:function(e){switch(e.type){case"paste":var html=TinyMCE_PastePlugin._clipboardHTML();var r,inst=tinyMCE.selectedInstance;if(inst&&(r=inst.getRng())&&r.text.length>0)tinyMCE.execCommand('delete');if(html&&html.length>0)tinyMCE.execCommand('mcePasteWord',false,html);tinyMCE.cancelEvent(e);return false;}return true;},_insertText:function(content,bLinebreaks){if(content&&content.length>0){if(bLinebreaks){if(tinyMCE.getParam("paste_create_paragraphs",true)){var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=tinyMCE.regexpReplace(content,"\r\n\r\n","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\r\r","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\n\n","</p><p>","gi");if((pos=content.indexOf('</p><p>'))!=-1){tinyMCE.execCommand("Delete");var node=tinyMCE.selectedInstance.getFocusElement();var breakElms=new Array();do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(tinyMCE.getParam("paste_create_linebreaks",true)){content=tinyMCE.regexpReplace(content,"\r\n","<br />","gi");content=tinyMCE.regexpReplace(content,"\r","<br />","gi");content=tinyMCE.regexpReplace(content,"\n","<br />","gi");}}tinyMCE.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);var cb;if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('before', content)");var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(new RegExp('<(!--)([^>]*)(--)>','g'),"");if(tinyMCE.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(tinyMCE.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(tinyMCE.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+TinyMCE_PastePlugin._reEscape(""+document.location)+'','gi'),'href="'+tinyMCE.settings['document_base_url']);content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!tinyMCE.settings['force_p_newlines']){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinyMCE.isMSIE&&!tinyMCE.settings['force_p_newlines']){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(tinyMCE.getParam("paste_convert_middot_lists",true)){var div=document.createElement("div");div.innerHTML=content;var className=tinyMCE.getParam("paste_unindented_list_class","unIndentedList");while(TinyMCE_PastePlugin._convertMiddots(div,"--list--"));while(TinyMCE_PastePlugin._convertMiddots(div,middot,className));while(TinyMCE_PastePlugin._convertMiddots(div,bull));content=div.innerHTML;}if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi,'<p>&nbsp;&nbsp;</p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b>&nbsp;<\/b>/gi,'<b>&nbsp;&nbsp;</b>');content=content.replace(/^(&nbsp;)*/gi,'');}content=content.replace(/--list--/gi,"");if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('after', content)");tinyMCE.execCommand("mceInsertContent",false,content);window.setTimeout('tinyMCE.execCommand("mceCleanup");',1);}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var mdot=String.fromCharCode(183);var bull=String.fromCharCode(8226);var nodes=div.getElementsByTagName("p");var prevul;for(var i=0;i<nodes.length;i++){var p=nodes[i];if(p.innerHTML.indexOf(search)==0){var ul=document.createElement("ul");if(class_name)ul.className=class_name;var li=document.createElement("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');ul.appendChild(li);var np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)){if(!prevul){prevul=ul;ul=document.createElement("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}var cp=np.nextSibling;var li=document.createElement("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}};tinyMCE.addPlugin("paste",TinyMCE_PastePlugin);
+/**
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
+ */
+
+/* Import plugin specific language pack */
+tinyMCE.importPluginLanguagePack('paste');
+
+var TinyMCE_PastePlugin = {
+ getInfo : function() {
+ return {
+ longname : 'Paste text/word',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',
+ version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
+ };
+ },
+
+ initInstance : function(inst) {
+ if (tinyMCE.isMSIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false))
+ tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent);
+ },
+
+ getControlHTML : function(cn) {
+ switch (cn) {
+ case "pastetext":
+ return tinyMCE.getButtonHTML(cn, 'lang_paste_text_desc', '{$pluginurl}/images/pastetext.gif', 'mcePasteText', true);
+
+ case "pasteword":
+ return tinyMCE.getButtonHTML(cn, 'lang_paste_word_desc', '{$pluginurl}/images/pasteword.gif', 'mcePasteWord', true);
+
+ case "selectall":
+ return tinyMCE.getButtonHTML(cn, 'lang_selectall_desc', '{$pluginurl}/images/selectall.gif', 'mceSelectAll', true);
+ }
+
+ return '';
+ },
+
+ execCommand : function(editor_id, element, command, user_interface, value) {
+ switch (command) {
+ case "mcePasteText":
+ if (user_interface) {
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false))
+ TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"), true);
+ else {
+ var template = new Array();
+ template['file'] = '../../plugins/paste/pastetext.htm'; // Relative to theme
+ template['width'] = 450;
+ template['height'] = 400;
+ var plain_text = "";
+ tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'});
+ }
+ } else
+ TinyMCE_PastePlugin._insertText(value['html'], value['linebreaks']);
+
+ return true;
+
+ case "mcePasteWord":
+ if (user_interface) {
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) {
+ TinyMCE_PastePlugin._insertWordContent(TinyMCE_PastePlugin._clipboardHTML());
+ } else {
+ var template = new Array();
+ template['file'] = '../../plugins/paste/pasteword.htm'; // Relative to theme
+ template['width'] = 450;
+ template['height'] = 400;
+ var plain_text = "";
+ tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'});
+ }
+ } else
+ TinyMCE_PastePlugin._insertWordContent(value);
+
+ return true;
+
+ case "mceSelectAll":
+ tinyMCE.execInstanceCommand(editor_id, 'selectall');
+ return true;
+
+ }
+
+ // Pass to next handler in chain
+ return false;
+ },
+
+ // Private plugin internal methods
+
+ _handlePasteEvent : function(e) {
+ switch (e.type) {
+ case "paste":
+ var html = TinyMCE_PastePlugin._clipboardHTML();
+ var r, inst = tinyMCE.selectedInstance;
+
+ // Removes italic, strong etc, the if was needed due to bug #1437114
+ if (inst && (r = inst.getRng()) && r.text.length > 0)
+ tinyMCE.execCommand('delete');
+
+ if (html && html.length > 0)
+ tinyMCE.execCommand('mcePasteWord', false, html);
+
+ tinyMCE.cancelEvent(e);
+ return false;
+ }
+
+ return true;
+ },
+
+ _insertText : function(content, bLinebreaks) {
+ if (content && content.length > 0) {
+ if (bLinebreaks) {
+ // Special paragraph treatment
+ if (tinyMCE.getParam("paste_create_paragraphs", true)) {
+ var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
+ for (var i=0; i<rl.length; i+=2)
+ content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
+
+ content = tinyMCE.regexpReplace(content, "\r\n\r\n", "</p><p>", "gi");
+ content = tinyMCE.regexpReplace(content, "\r\r", "</p><p>", "gi");
+ content = tinyMCE.regexpReplace(content, "\n\n", "</p><p>", "gi");
+
+ // Has paragraphs
+ if ((pos = content.indexOf('</p><p>')) != -1) {
+ tinyMCE.execCommand("Delete");
+
+ var node = tinyMCE.selectedInstance.getFocusElement();
+
+ // Get list of elements to break
+ var breakElms = new Array();
+
+ do {
+ if (node.nodeType == 1) {
+ // Don't break tables and break at body
+ if (node.nodeName == "TD" || node.nodeName == "BODY")
+ break;
+
+ breakElms[breakElms.length] = node;
+ }
+ } while(node = node.parentNode);
+
+ var before = "", after = "</p>";
+ before += content.substring(0, pos);
+
+ for (var i=0; i<breakElms.length; i++) {
+ before += "</" + breakElms[i].nodeName + ">";
+ after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">";
+ }
+
+ before += "<p>";
+ content = before + content.substring(pos+7) + after;
+ }
+ }
+
+ if (tinyMCE.getParam("paste_create_linebreaks", true)) {
+ content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
+ content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
+ content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
+ }
+ }
+
+ tinyMCE.execCommand("mceInsertRawHTML", false, content);
+ }
+ },
+
+ _insertWordContent : function(content) {
+ if (content && content.length > 0) {
+ // Cleanup Word content
+ var bull = String.fromCharCode(8226);
+ var middot = String.fromCharCode(183);
+ var cb;
+
+ if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "")
+ content = eval(cb + "('before', content)");
+
+ var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
+ for (var i=0; i<rl.length; i+=2)
+ content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
+
+ if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) {
+ content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>');
+ }
+
+ content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--");
+ content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>");
+ content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list
+ content = content.replace(/<o:p><\/o:p>/gi, "");
+ content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks
+ content = content.replace(new RegExp('<(!--)([^>]*)(--)>', 'g'), ""); // Word comments
+
+ if (tinyMCE.getParam("paste_remove_spans", true))
+ content = content.replace(/<\/?span[^>]*>/gi, "");
+
+ if (tinyMCE.getParam("paste_remove_styles", true))
+ content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3");
+
+ content = content.replace(/<\/?font[^>]*>/gi, "");
+
+ // Strips class attributes.
+ switch (tinyMCE.getParam("paste_strip_class_attributes", "all")) {
+ case "all":
+ content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
+ break;
+
+ case "mso":
+ content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3");
+ break;
+ }
+
+ content = content.replace(new RegExp('href="?' + TinyMCE_PastePlugin._reEscape("" + document.location) + '', 'gi'), 'href="' + tinyMCE.settings['document_base_url']);
+ content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
+ content = content.replace(/<\\?\?xml[^>]*>/gi, "");
+ content = content.replace(/<\/?\w+:[^>]*>/gi, "");
+ content = content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi, ""); // Remove pagebreaks
+ content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks
+
+ // content = content.replace(/\/?&nbsp;*/gi, ""); &nbsp;
+ // content = content.replace(/<p>&nbsp;<\/p>/gi, '');
+
+ if (!tinyMCE.settings['force_p_newlines']) {
+ content = content.replace('', '' ,'gi');
+ content = content.replace('</p>', '<br /><br />' ,'gi');
+ }
+
+ if (!tinyMCE.isMSIE && !tinyMCE.settings['force_p_newlines']) {
+ content = content.replace(/<\/?p[^>]*>/gi, "");
+ }
+
+ content = content.replace(/<\/?div[^>]*>/gi, "");
+
+ // Convert all middlot lists to UL lists
+ if (tinyMCE.getParam("paste_convert_middot_lists", true)) {
+ var div = document.createElement("div");
+ div.innerHTML = content;
+
+ // Convert all middot paragraphs to li elements
+ var className = tinyMCE.getParam("paste_unindented_list_class", "unIndentedList");
+
+ while (TinyMCE_PastePlugin._convertMiddots(div, "--list--")) ; // bull
+ while (TinyMCE_PastePlugin._convertMiddots(div, middot, className)) ; // Middot
+ while (TinyMCE_PastePlugin._convertMiddots(div, bull)) ; // bull
+
+ content = div.innerHTML;
+ }
+
+ // Replace all headers with strong and fix some other issues
+ if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) {
+ content = content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi, '<p>&nbsp;&nbsp;</p>');
+ content = content.replace(/<h[1-6]>/gi, '<p><b>');
+ content = content.replace(/<\/h[1-6]>/gi, '</b></p>');
+ content = content.replace(/<b>&nbsp;<\/b>/gi, '<b>&nbsp;&nbsp;</b>');
+ content = content.replace(/^(&nbsp;)*/gi, '');
+ }
+
+ content = content.replace(/--list--/gi, ""); // Remove --list--
+
+ if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "")
+ content = eval(cb + "('after', content)");
+
+ // Insert cleaned content
+ tinyMCE.execCommand("mceInsertContent", false, content);
+
+ if (tinyMCE.getParam('paste_force_cleanup_wordpaste', true))
+ window.setTimeout('tinyMCE.execCommand("mceCleanup");', 1); // Do normal cleanup detached from this thread
+ }
+ },
+
+ _reEscape : function(s) {
+ var l = "?.\\*[](){}+^$:";
+ var o = "";
+
+ for (var i=0; i<s.length; i++) {
+ var c = s.charAt(i);
+
+ if (l.indexOf(c) != -1)
+ o += '\\' + c;
+ else
+ o += c;
+ }
+
+ return o;
+ },
+
+ _convertMiddots : function(div, search, class_name) {
+ var mdot = String.fromCharCode(183);
+ var bull = String.fromCharCode(8226);
+
+ var nodes = div.getElementsByTagName("p");
+ var prevul;
+ for (var i=0; i<nodes.length; i++) {
+ var p = nodes[i];
+
+ // Is middot
+ if (p.innerHTML.indexOf(search) == 0) {
+ var ul = document.createElement("ul");
+
+ if (class_name)
+ ul.className = class_name;
+
+ // Add the first one
+ var li = document.createElement("li");
+ li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
+ ul.appendChild(li);
+
+ // Add the rest
+ var np = p.nextSibling;
+ while (np) {
+ // If the node is whitespace, then
+ // ignore it and continue on.
+ if (np.nodeType == 3 && new RegExp('^\\s$', 'm').test(np.nodeValue)) {
+ np = np.nextSibling;
+ continue;
+ }
+
+ if (search == mdot) {
+ if (np.nodeType == 1 && new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)) {
+ // Second level of nesting
+ if (!prevul) {
+ prevul = ul;
+ ul = document.createElement("ul");
+ prevul.appendChild(ul);
+ }
+ np.innerHTML = np.innerHTML.replace(/^o/, '');
+ } else {
+ // Pop the stack if we're going back up to the first level
+ if (prevul) {
+ ul = prevul;
+ prevul = null;
+ }
+ // Not element or middot paragraph
+ if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
+ break;
+ }
+ } else {
+ // Not element or middot paragraph
+ if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
+ break;
+ }
+
+ var cp = np.nextSibling;
+ var li = document.createElement("li");
+ li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
+ np.parentNode.removeChild(np);
+ ul.appendChild(li);
+ np = cp;
+ }
+
+ p.parentNode.replaceChild(ul, p);
+
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ _clipboardHTML : function() {
+ var div = document.getElementById('_TinyMCE_clipboardHTML');
+
+ if (!div) {
+ var div = document.createElement('DIV');
+ div.id = '_TinyMCE_clipboardHTML';
+
+ with (div.style) {
+ visibility = 'hidden';
+ overflow = 'hidden';
+ position = 'absolute';
+ width = 1;
+ height = 1;
+ }
+
+ document.body.appendChild(div);
+ }
+
+ div.innerHTML = '';
+ var rng = document.body.createTextRange();
+ rng.moveToElementText(div);
+ rng.execCommand('Paste');
+ var html = div.innerHTML;
+ div.innerHTML = '';
+ return html;
+ }
+};
+
+tinyMCE.addPlugin("paste", TinyMCE_PastePlugin);
+
diff --git a/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js b/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js
index 927745b..4c07691 100644
--- a/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js
+++ b/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js
@@ -15,6 +15,10 @@ function saveContent() {
function onLoadInit() {
tinyMCEPopup.resizeToInnerSize();
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
resizeInputs();
}
diff --git a/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js b/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js
index c56ea81..b243a10 100644
--- a/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js
+++ b/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js
@@ -25,7 +25,13 @@ var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
function initIframe(doc) {
var dir = tinyMCE.selectedInstance.settings['directionality'];
+
doc.body.dir = dir;
+
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ doc.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
resizeInputs();
}
diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
index a596b83..ede6576 100644
--- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
@@ -575,7 +575,7 @@ function wpautop(pee) {
pee = pee.replace(new RegExp('(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)', 'gi'), "$1\n\n");
pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
- pee = pee.replace(new RegExp('\n*([^\Z]+?)\\n{2}', 'mg'), "<p>$1</p>\n");
+ pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
diff --git a/wp-includes/js/tinymce/themes/advanced/charmap.htm b/wp-includes/js/tinymce/themes/advanced/charmap.htm
index 9dac168..fbd472b 100644
--- a/wp-includes/js/tinymce/themes/advanced/charmap.htm
+++ b/wp-includes/js/tinymce/themes/advanced/charmap.htm
@@ -6,7 +6,7 @@
<script language="javascript" type="text/javascript" src="jscripts/charmap.js"></script>
<base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="display: none">
+<body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
<table align="center" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2" class="title">{$lang_theme_charmap_title}</td>
diff --git a/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm
index 725466e..e5fdc9f 100644
--- a/wp-includes/js/tinymce/themes/advanced/color_picker.htm
+++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm
@@ -5,7 +5,7 @@
<script language="javascript" type="text/javascript" src="jscripts/color_picker.js"></script>
<base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="margin: 3px; display: none">
+<body onload="tinyMCEPopup.executeOnLoad('init();');" style="margin: 3px; display: none">
<div align="center">
<script language="javascript" type="text/javascript">renderColorMap();</script>
</div>
diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
index 11f75df..182e791 100644
--- a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
+++ b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
@@ -14,6 +14,11 @@ body {
border: 1px dashed #BBBBBB !important;
}
+div.mceVisualAid {
+ background-image:url('../images/spacer.gif');
+ visibility: visible !important;
+}
+
.mceItemAnchor {
width: 12px;
line-height: 6px;
diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
index 3b42925..079470c 100644
--- a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
+++ b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
@@ -312,6 +312,10 @@ h3 {
height: 190px;
}
+label.msg { display: none; }
+label.invalid { color: #EE0000; display: inline; }
+input.invalid { border: 1px solid #EE0000; }
+
/* Disables the advanced tab in the table plugin. */
/*
#table #advanced_tab {
diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
index 04fccc7..e70405d 100644
--- a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
+++ b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
@@ -1,348 +1,97 @@
/* This file contains the CSS data for the editor UI of TinyMCE instances */
-.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {
- border: 0; margin: 0; padding: 0; background: transparent;
-}
-
-.mceSeparatorLine {
- border: 0;
- padding: 0;
- margin-left: 4px;
- margin-right: 2px;
-}
-
-.mceSelectList {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 7pt !important;
- font-weight: normal;
- margin-top: 3px;
- padding: 0;
- display: inline;
- vertical-align: top;
- background-color: #F0F0EE;
-}
-
-.mceLabel, .mceLabelDisabled {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 9pt;
-}
-
-.mceLabel {
- color: #000000;
-}
-
-.mceLabelDisabled {
- cursor: text;
- color: #999999;
-}
-
-.mceEditor {
- background: #F0F0EE;
- border: 1px solid #cccccc;
- padding: 0;
- margin: 0;
-}
-
-.mceEditorArea {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- background: #FFFFFF;
- padding: 0;
- margin: 0;
-}
-
-.mceToolbarTop, .mceToolbarBottom {
- background: #F0F0EE;
- line-height: 1px;
- font-size: 1px;
-}
-
-.mceToolbarTop {
- border-bottom: 1px solid #cccccc;
- padding-bottom: 1px;
-}
-
-.mceToolbarBottom {
- border-top: 1px solid #cccccc;
-}
-
-.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {
- height: 20px;
-}
-
-.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 9pt;
- padding: 2px;
- line-height: 16px;
- overflow: visible;
-}
-
-.mceStatusbarTop {
- border-bottom: 1px solid #cccccc;
-}
-
-.mceStatusbarBottom {
- border-top: 1px solid #cccccc;
-}
-
-.mceStatusbar {
- border-bottom: 1px solid #cccccc;
-}
-
-.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {
- text-decoration: none;
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 9pt;
- color: #000000;
-}
-
-.mcePathItem:hover {
- text-decoration: underline;
-}
-
-.mceStatusbarPathText {
- float: left;
-}
-
-.mceStatusbarResize {
- float: right;
- background-image: url('../images/statusbar_resize.gif');
- background-repeat: no-repeat;
- width: 11px;
- height: 20px;
- cursor: se-resize;
-}
-
-.mceResizeBox {
- width: 10px;
- height: 10px;
- display: none;
- border: 1px dotted gray;
- margin: 0;
- padding: 0;
-}
+.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {border: 0; margin: 0; padding: 0; background: transparent;}
+.mceSeparatorLine {border: 0; padding: 0; margin-left: 4px; margin-right: 2px;}
+.mceSelectList {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 7pt !important; font-weight: normal; margin-top: 3px; padding: 0; display: inline; vertical-align: top; background-color: #F0F0EE;}
+.mceLabel, .mceLabelDisabled {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt;}
+.mceLabel {color: #000000;}
+.mceLabelDisabled {cursor: text; color: #999999;}
+.mceEditor {background: #F0F0EE; border: 1px solid #cccccc; padding: 0; margin: 0;}
+.mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; background: #FFFFFF; padding: 0; margin: 0; }
+.mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;}
+.mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;}
+.mceToolbarBottom {border-top: 1px solid #cccccc;}
+.mceToolbarContainer {position: relative; left: 0; top: 0; display: block;}
+.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;}
+.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px; overflow: visible;}
+.mceStatusbarTop {border-bottom: 1px solid #cccccc;}
+.mceStatusbarBottom {border-top: 1px solid #cccccc;}
+.mceStatusbar {border-bottom: 1px solid #cccccc;}
+.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {text-decoration: none; font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; color: #000000;}
+.mcePathItem:hover {text-decoration: underline;}
+.mceStatusbarPathText {float: left;}
+.mceStatusbarResize {float: right; background-image: url('../images/statusbar_resize.gif'); background-repeat: no-repeat; width: 11px; height: 20px; cursor: se-resize;}
+.mceResizeBox {width: 10px; height: 10px; display: none; border: 1px dotted gray; margin: 0; padding: 0;}
+.mceEditorIframe {border: 0;}
/* Button CSS rules */
-a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {
- width: 20px;
- height: 20px;
- cursor: default;
- margin-top: 1px;
- margin-left: 1px;
-}
-
-a.mceButtonDisabled img {
- border: 0 !important;
-}
-
-a.mceButtonNormal img, a.mceButtonSelected img {
- border: 1px solid #F0F0EE !important;
-}
-
-a.mceButtonSelected img {
- border: 1px solid #6779AA !important;
- background-color: #D4D5D8;
-}
-
-a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {
- border: 1px solid #0A246A !important;
- cursor: default;
- background-color: #B6BDD2;
-}
-
-a.mceButtonDisabled img {
- -moz-opacity:0.3;
- opacity: 0.3;
- border: 1px solid #F0F0EE !important;
- cursor: default;
-}
-
-a.mceTiledButton img {
- background-image: url('../images/buttons.gif');
- background-repeat: no-repeat;
-}
-
-/* MSIE specific rules */
-
-* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {
- border: 0 !important;
- margin-top: 2px;
- margin-bottom: 1px;
-}
-
-* html a.mceButtonDisabled img {
- filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
- border: 0 !important;
-}
-
-* html a.mceButtonDisabled {
- border: 1px solid #F0F0EE !important;
-}
-
-* html a.mceButtonNormal, * html a.mceButtonSelected {
- border: 1px solid #F0F0EE !important;
- cursor: default;
-}
-
-* html a.mceButtonSelected {
- border: 1px solid #6779AA !important;
- background-color: #D4D5D8;
-}
-
-* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {
- border: 1px solid #0A246A !important;
- cursor: default;
- background-color: #B6BDD2;
-}
-
-* html .mceSelectList {
- margin-top: 2px;
-}
+a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {width: 20px; height: 20px; cursor: default; margin-top: 1px; margin-left: 1px;}
+a.mceButtonDisabled img {border: 0 !important;}
+a.mceButtonNormal img, a.mceButtonSelected img {border: 1px solid #F0F0EE !important;}
+a.mceButtonSelected img {border: 1px solid #6779AA !important; background-color: #D4D5D8;}
+a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {border: 1px solid #0A246A !important; cursor: default; background-color: #B6BDD2;}
+a.mceButtonDisabled img {-moz-opacity:0.3; opacity: 0.3; border: 1px solid #F0F0EE !important; cursor: default;}
+a.mceTiledButton img {background-image: url('../images/buttons.gif'); background-repeat: no-repeat;}
/* Menu button CSS rules */
-span.mceMenuButton img, span.mceMenuButtonSelected img {
- border: 1px solid #F0F0EE;
- margin-left: 1px;
-}
-
-span.mceMenuButtonSelected img {
- border: 1px solid #6779AA;
- background-color: #B6BDD2;
-}
-
-span.mceMenuButtonSelected img.mceMenuButton {
- border: 1px solid #F0F0EE;
- background-color: transparent;
-}
-
-span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {
- border-left: 0;
- margin-left: 0;
-}
-
-span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {
- border: 1px solid #0A246A;
- background-color: #B6BDD2;
-}
-
-span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {
- border-left: 0;
-}
-
-span.mceMenuButtonFocus img {
- border: 1px solid gray;
- border-right: 0;
- margin-left: 1px;
- background-color: #F5F4F2;
-}
-
-span.mceMenuButtonFocus img.mceMenuButton {
- border: 1px solid gray;
- border-left: 1px solid #F5F4F2;
- margin-left: 0;
-}
-
-/* Menu button MSIE specific rules */
-
-* html span.mceMenuButton, * html span.mceMenuButtonFocus {
- position: relative;
- left: 0;
- top: 0;
-}
-
-* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {
- position: relative;
- top: 1px;
-}
-
-* html span.mceMenuHover img {
- border: 1px solid #0A246A;
- background-color: #B6BDD2;
-}
-
-* html span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {
- border: 1px solid #0A246A;
- background-color: #B6BDD2;
- border-left: 0;
-}
+span.mceMenuButton img, span.mceMenuButtonSelected img {border: 1px solid #F0F0EE; margin-left: 1px;}
+span.mceMenuButtonSelected img {border: 1px solid #6779AA; background-color: #B6BDD2;}
+span.mceMenuButtonSelected img.mceMenuButton {border: 1px solid #F0F0EE; background-color: transparent;}
+span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {border-left: 0; margin-left: 0;}
+span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {border: 1px solid #0A246A; background-color: #B6BDD2;}
+span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {border-left: 0;}
+span.mceMenuButtonFocus img {border: 1px solid gray; border-right: 0; margin-left: 1px; background-color: #F5F4F2;}
+span.mceMenuButtonFocus img.mceMenuButton {border: 1px solid gray; border-left: 1px solid #F5F4F2; margin-left: 0;}
+span.mceMenuHover img {border: 1px solid #0A246A; background-color: #B6BDD2;}
+span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A246A; background-color: #B6BDD2; border-left: 0;}
/* Menu */
-.mceMenu {
- position: absolute;
- left: 0;
- top: 0;
- display: none;
- z-index: 100;
- background-color: white;
- border: 1px solid gray;
- font-weight: normal;
-}
-
-.mceMenu a, .mceMenuTitle, .mceMenuDisabled {
- display: block;
- width: 100%;
- text-decoration: none;
- background-color: white;
- font-family: Tahoma, Verdana, Arial, Helvetica;
- font-size: 11px;
- line-height: 20px;
- color: black;
-}
-
-.mceMenu a:hover {
- background-color: #B6BDD2;
- color: black;
-}
-
-.mceMenu span {
- padding-left: 10px;
- padding-right: 10px;
- display: block;
- line-height: 20px;
-}
-
-.mceMenuSeparator {
- border-bottom: 1px solid gray;
- background-color: gray;
- height: 1px;
-}
-
-.mceMenuTitle span {
- padding-left: 5px;
-}
-
-.mceMenuTitle {
- background-color: #DDDDDD;
- font-weight: bold;
-}
-
-.mceMenuDisabled {
- color: gray;
-}
-
-span.mceMenuSelectedItem {
- background-image: url('../images/menu_check.gif');
- background-repeat: no-repeat;
- background-position: 5px 8px;
- padding-left: 20px;
-}
-
-span.mceMenuCheckItem {
- padding-left: 20px;
-}
-
-span.mceMenuLine {
- display: block;
- position: absolute;
- left: 0;
- top: -1px;
- background-color: #F5F4F2;
- width: 30px;
- height: 1px;
- overflow: hidden;
- padding-left: 0;
- padding-right: 0;
-}
+.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 100; background-color: white; border: 1px solid gray; font-weight: normal;}
+.mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block; width: 100%; text-decoration: none; background-color: white; font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 11px; line-height: 20px; color: black;}
+.mceMenu a:hover {background-color: #B6BDD2; color: black; text-decoration: none !important;}
+.mceMenu span {padding-left: 10px; padding-right: 10px; display: block; line-height: 20px;}
+.mceMenuSeparator {border-bottom: 1px solid gray; background-color: gray; height: 1px;}
+.mceMenuTitle span {padding-left: 5px;}
+.mceMenuTitle {background-color: #DDDDDD; font-weight: bold;}
+.mceMenuDisabled {color: gray;}
+span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif'); background-repeat: no-repeat; background-position: 5px 8px; padding-left: 20px;}
+span.mceMenuCheckItem {padding-left: 20px;}
+span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0; padding-right: 0;}
+.mceColors table, .mceColors td {margin: 0; padding: 2px;}
+a.mceMoreColors {width: 130px; margin: 0; padding: 0; margin-left: 3px; margin-bottom: 3px; text-align: center; border: 1px solid white;}
+.mceColorPreview {position: absolute; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;}
+a.mceMoreColors:hover {border: 1px solid #0A246A;}
+.mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;}
+
+/* MSIE 6 specific rules */
+
+* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;}
+* html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;}
+* html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;}
+* html a.mceButtonNormal, * html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;}
+* html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;}
+* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;}
+* html .mceSelectList {margin-top: 2px;}
+* html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
+* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; top: 1px;}
+* html a.mceMoreColors {width: 132px;}
+* html .mceColors td a {width: 10px; height: 10px;}
+* html .mceColorPreview {margin-left: 2px; margin-top: 14px;}
+
+/* MSIE 7 specific rules */
+
+*:first-child+html a.mceButtonNormal img, *:first-child+html a.mceButtonSelected img, *:first-child+html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;}
+*:first-child+html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;}
+*:first-child+html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;}
+*:first-child+html a.mceButtonNormal, *:first-child+html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;}
+*:first-child+html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;}
+*:first-child+html a.mceButtonNormal:hover, *:first-child+html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;}
+*:first-child+html .mceSelectList {margin-top: 2px;}
+*:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
+*:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;}
+*:first-child+html a.mceMoreColors {width: 132px;}
+*:first-child+html .mceColors td a {width: 10px; height: 10px;}
+*:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;}
diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js
index 052914e..2285832 100644
--- a/wp-includes/js/tinymce/themes/advanced/editor_template.js
+++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: editor_template_src.js,v $
- * $Revision: 1.96 $
- * $Date: 2006/04/18 13:32:52 $
+ * $Id: editor_template_src.js 129 2006-10-23 09:45:17Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
@@ -12,6 +10,7 @@ tinyMCE.importThemeLanguagePack('advanced');
var TinyMCE_AdvancedTheme = {
// Private theme fields
+ _defColors : "000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF",
_autoImportCSSClasses : true,
_resizer : {},
_buttons : [
@@ -43,25 +42,28 @@ var TinyMCE_AdvancedTheme = {
['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'],
['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
- ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'mceForeColor', true],
- ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'mceBackColor', true],
+ ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
+ ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true],
['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument']
],
- _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells',
+ _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells,delete_table',
/**
* Returns HTML code for the specificed control.
*/
getControlHTML : function(button_name) {
- var i, x;
+ var i, x, but;
// Lookup button in button list
for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
- var but = TinyMCE_AdvancedTheme._buttons[i];
+ but = TinyMCE_AdvancedTheme._buttons[i];
+
+ if (but[0] == button_name && (button_name == "forecolor" || button_name == "backcolor"))
+ return tinyMCE.getMenuButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3] + "Menu", but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
if (but[0] == button_name)
return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
@@ -153,6 +155,18 @@ var TinyMCE_AdvancedTheme = {
*/
execCommand : function(editor_id, element, command, user_interface, value) {
switch (command) {
+ case 'mceHelp':
+ tinyMCE.openWindow({
+ file : 'about.htm',
+ width : 480,
+ height : 380
+ }, {
+ tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
+ tinymce_releasedate : tinyMCE.releaseDate,
+ inline : "yes"
+ });
+ return true;
+
case "mceLink":
var inst = tinyMCE.getInstanceById(editor_id);
var doc = inst.getDoc();
@@ -317,41 +331,94 @@ var TinyMCE_AdvancedTheme = {
return true;
- case "mceForeColor":
- var template = new Array();
- var elm = tinyMCE.selectedInstance.getFocusElement();
- var inputColor = tinyMCE.getAttrib(elm, "color");
+ case "forecolor":
+ var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm;
+
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ if (!fcp.exists()) {
+ fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
+ elm = fcp.getElement();
+ elm._editor_id = editor_id;
+ elm._command = "forecolor";
+ elm._switchId = editor_id + "_forecolor";
+ tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
+ }
+
+ img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0];
+ p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
+
+ fcp.moveTo(p.absLeft, p.absTop);
+ fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor;
+ fcp.show();
+
+ return false;
+
+ case "forecolorMenu":
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ // Create color layer
+ var ml = new TinyMCE_Layer(editor_id + '_fcMenu');
- if (inputColor == '')
- inputColor = elm.style.color;
+ if (!ml.exists())
+ ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor'));
- if (!inputColor)
- inputColor = "#000000";
+ tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus');
+ ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl');
- template['file'] = 'color_picker.htm';
- template['width'] = 220;
- template['height'] = 190;
+ ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
- tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
+ if (tinyMCE.isOpera)
+ ml.moveBy(0, -2);
+
+ ml.show();
return true;
- case "mceBackColor":
- var template = new Array();
- var elm = tinyMCE.selectedInstance.getFocusElement();
- var inputColor = elm.style.backgroundColor;
+ case "HiliteColor":
+ var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img;
+
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ if (!bcp.exists()) {
+ bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
+ elm = bcp.getElement();
+ elm._editor_id = editor_id;
+ elm._command = "HiliteColor";
+ elm._switchId = editor_id + "_backcolor";
+ tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
+ }
+
+ img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0];
+ p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
+
+ bcp.moveTo(p.absLeft, p.absTop);
+ bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor;
+ bcp.show();
+
+ return false;
+
+ case "HiliteColorMenu":
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ // Create color layer
+ var ml = new TinyMCE_Layer(editor_id + '_bcMenu');
+
+ if (!ml.exists())
+ ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor'));
- if (!inputColor)
- inputColor = "#000000";
+ tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus');
+ ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl');
- template['file'] = 'color_picker.htm';
- template['width'] = 220;
- template['height'] = 190;
+ ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
- template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
- template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);
+ if (tinyMCE.isOpera)
+ ml.moveBy(0, -2);
- tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
- //mceBackColor
+ ml.show();
return true;
case "mceColorPicker":
@@ -433,7 +500,7 @@ var TinyMCE_AdvancedTheme = {
*/
getEditorTemplate : function(settings, editorId) {
function removeFromArray(in_array, remove_array) {
- var outArray = new Array();
+ var outArray = new Array(), skip;
for (var i=0; i<in_array.length; i++) {
skip = false;
@@ -530,10 +597,10 @@ var TinyMCE_AdvancedTheme = {
toolbarHTML += '<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"></a>';
// Setup template html
- template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
+ template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>';
if (toolbarLocation == "top") {
- template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
+ template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
}
if (statusbarLocation == "top") {
@@ -544,7 +611,7 @@ var TinyMCE_AdvancedTheme = {
template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
if (toolbarLocation == "bottom") {
- template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
+ template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
}
// External toolbar changes
@@ -615,9 +682,10 @@ var TinyMCE_AdvancedTheme = {
var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
- for (var j=0; j<curContainer.length; j++) {
+ curContainer = removeFromArray(curContainer, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
+
+ for (var j=0; j<curContainer.length; j++)
curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
- }
if (curContainer.length > 0) {
curContainerHTML += "<br />";
@@ -664,10 +732,34 @@ var TinyMCE_AdvancedTheme = {
inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink');
},
+ _handleMenuEvent : function(e) {
+ var te = tinyMCE.isMSIE ? window.event.srcElement : e.target;
+ tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId));
+
+ if (e.type == "click")
+ tinyMCE.execInstanceCommand(te._editor_id, te._command);
+ },
+
+ _hideMenus : function(id) {
+ var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu');
+
+ if (fcml.exists() && fcml.isVisible()) {
+ tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton');
+ fcml.hide();
+ }
+
+ if (bcml.exists() && bcml.isVisible()) {
+ tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton');
+ bcml.hide();
+ }
+ },
+
/**
* Node change handler.
*/
handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
+ var alignNode, breakOut, classNode;
+
function selectByValue(select_elm, value, first_index) {
first_index = typeof(first_index) == "undefined" ? false : true;
@@ -702,6 +794,7 @@ var TinyMCE_AdvancedTheme = {
var pathElm = document.getElementById(editor_id + "_path");
var inst = tinyMCE.getInstanceById(editor_id);
var doc = inst.getDoc();
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
if (pathElm) {
// Get node path
@@ -727,6 +820,9 @@ var TinyMCE_AdvancedTheme = {
var nodeName = path[i].nodeName.toLowerCase();
var nodeData = "";
+ if (nodeName.indexOf("html:") == 0)
+ nodeName = nodeName.substring(5);
+
if (nodeName == "b") {
nodeName = "strong";
}
@@ -781,7 +877,7 @@ var TinyMCE_AdvancedTheme = {
nodeData += "src: " + src + " ";
}
- if (getAttrib(path[i], 'href') != "") {
+ if (path[i].nodeName == 'A' && getAttrib(path[i], 'href') != "") {
var href = tinyMCE.getAttrib(path[i], "mce_href");
if (href == "")
@@ -790,9 +886,10 @@ var TinyMCE_AdvancedTheme = {
nodeData += "href: " + href + " ";
}
- if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) {
- nodeName = "flash";
- nodeData = "src: " + path[i].getAttribute('title');
+ className = tinyMCE.getAttrib(path[i], "class");
+ if ((nodeName == "img" || nodeName == "span") && className.indexOf('mceItem') != -1) {
+ nodeName = className.replace(/mceItem([a-z]+)/gi, '$1').toLowerCase();
+ nodeData = path[i].getAttribute('title');
}
if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") {
@@ -1027,7 +1124,7 @@ var TinyMCE_AdvancedTheme = {
break;
case "IMG":
- if (getAttrib(node, 'name').indexOf('mce_') != 0) {
+ if (getAttrib(node, 'name').indexOf('mce_') != 0 && tinyMCE.getAttrib(node, 'class').indexOf('mceItem') == -1) {
tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected');
}
break;
@@ -1148,6 +1245,9 @@ var TinyMCE_AdvancedTheme = {
inst.iframeElement.style.width = (iw + dx) + "px";
}
}
+
+ // Remove pesky table controls
+ inst.useCSS = false;
},
/**
@@ -1255,6 +1355,29 @@ var TinyMCE_AdvancedTheme = {
}
},
+ _getColorHTML : function(id, n, cm) {
+ var i, h, cl;
+
+ h = '<span class="mceMenuLine"></span>';
+ cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(',');
+
+ h += '<table class="mceColors"><tr>';
+ for (i=0; i<cl.length; i++) {
+ c = 'tinyMCE.execInstanceCommand(\'' + id + '\', \'' + cm + '\', false, \'#' + cl[i] + '\');';
+ h += '<td><a href="javascript:' + c + '" style="background-color: #' + cl[i] + '" onclick="' + c + ';return false;"></a></td>';
+
+ if ((i+1) % 8 == 0)
+ h += '</tr><tr>';
+ }
+
+ h += '</tr></table>';
+ /*
+ h += '<a href="" class="mceMoreColors">More colors</a>';
+ */
+
+ return h;
+ },
+
_insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
tinyMCE.execCommand('mceBeginUndoLevel');
diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template_src.js b/wp-includes/js/tinymce/themes/advanced/editor_template_src.js
deleted file mode 100644
index e69de29..0000000
--- a/wp-includes/js/tinymce/themes/advanced/editor_template_src.js
+++ /dev/null
diff --git a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif b/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif
index 8a532e5..d03e206 100644
--- a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif
+++ b/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif
Binary files differ
diff --git a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
index 6196350..5ad99a7 100644
--- a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
+++ b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
Binary files differ
diff --git a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif b/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif
index d5e3814..8b70361 100644
--- a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif
+++ b/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif
Binary files differ
diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
index b7dadc6..8395340 100644
--- a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
+++ b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
@@ -3,29 +3,25 @@ function saveContent() {
tinyMCE.closeWindow(window);
}
-// Fixes some charcode issues
-function fixContent(html) {
-/* html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
- html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n');
- html = tinyMCE.regexpReplace(html, '<br />','<br />\n','gi');
- html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');*/
- return html;
-}
-
function onLoadInit() {
tinyMCEPopup.resizeToInnerSize();
- document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
+ document.getElementById('htmlSource').value = tinyMCE.getContent(tinyMCE.getWindowArg('editor_id'));
+
resizeInputs();
if (tinyMCE.getParam("theme_advanced_source_editor_wrap", true)) {
setWrap('soft');
- document.forms[0].wraped.checked = true;
+ document.getElementById('wraped').checked = true;
}
}
function setWrap(val) {
- var s = document.forms[0].htmlSource;
+ var s = document.getElementById('htmlSource');
s.wrap = val;
@@ -48,6 +44,8 @@ function toggleWordWrap(elm) {
var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
function resizeInputs() {
+ var el = document.getElementById('htmlSource');
+
if (!tinyMCE.isMSIE) {
wHeight = self.innerHeight-80;
wWidth = self.innerWidth-16;
@@ -56,11 +54,7 @@ function resizeInputs() {
wWidth = document.body.clientWidth - 16;
}
- document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';
- document.forms[0].htmlSource.style.width = Math.abs(wWidth) + 'px';
+ el.style.height = Math.abs(wHeight) + 'px';
+ el.style.width = Math.abs(wWidth) + 'px';
}
-function renderWordWrap() {
- if (tinyMCE.isMSIE || tinyMCE.isGecko)
- document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>');
-}
diff --git a/wp-includes/js/tinymce/themes/advanced/langs/en.js b/wp-includes/js/tinymce/themes/advanced/langs/en.js
index ca72676..fd915ea 100644
--- a/wp-includes/js/tinymce/themes/advanced/langs/en.js
+++ b/wp-includes/js/tinymce/themes/advanced/langs/en.js
@@ -38,6 +38,11 @@ theme_h3 : 'Heading 3',
theme_h4 : 'Heading 4',
theme_h5 : 'Heading 5',
theme_h6 : 'Heading 6',
+theme_blockquote : 'Blockquote',
+theme_code : 'Code',
+theme_samp : 'Code sample',
+theme_dt : 'Definition term ',
+theme_dd : 'Definition description',
theme_colorpicker_title : 'Select a color',
theme_colorpicker_apply : 'Apply',
theme_forecolor_desc : 'Select text color',
@@ -72,5 +77,6 @@ loaded_plugins : 'Loaded plugins',
help : 'Help',
not_set : '-- Not set --',
close : 'Close',
-toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X'
+toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X',
+invalid_data : 'Error: Invalid values entered, these are marked in red.'
});
diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js
index 643aab4..ecd78a2 100644
--- a/wp-includes/js/tinymce/tiny_mce.js
+++ b/wp-includes/js/tinymce/tiny_mce.js
@@ -2,9 +2,11 @@
/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */
function TinyMCE_Engine() {
+ var ua;
+
this.majorVersion = "2";
- this.minorVersion = "0.6.1";
- this.releaseDate = "2006-05-04";
+ this.minorVersion = "0.8";
+ this.releaseDate = "2006-10-23";
this.instances = new Array();
this.switchClassCache = new Array();
@@ -15,12 +17,17 @@ function TinyMCE_Engine() {
this.configs = new Array();
this.currentConfig = 0;
this.eventHandlers = new Array();
+ this.log = new Array();
+ this.undoLevels = [];
+ this.undoIndex = 0;
+ this.typingUndoIndex = -1;
// Browser check
- var ua = navigator.userAgent;
+ ua = navigator.userAgent;
this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);
this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);
+ this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1);
this.isGecko = ua.indexOf('Gecko') != -1;
this.isSafari = ua.indexOf('Safari') != -1;
this.isOpera = ua.indexOf('Opera') != -1;
@@ -42,13 +49,20 @@ function TinyMCE_Engine() {
this.isSafari = false;
}
+ this.isIE = this.isMSIE;
+ this.isRealIE = this.isMSIE && !this.isOpera;
+
// TinyMCE editor id instance counter
this.idCounter = 0;
};
TinyMCE_Engine.prototype = {
init : function(settings) {
- var theme;
+ var theme, nl, baseHREF = "", i;
+
+ // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry.
+ if (this.isMSIE5_0)
+ return;
this.settings = settings;
@@ -60,6 +74,13 @@ TinyMCE_Engine.prototype = {
if (!tinyMCE.baseURL) {
var elements = document.getElementsByTagName('script');
+ // If base element found, add that infront of baseURL
+ nl = document.getElementsByTagName('base');
+ for (i=0; i<nl.length; i++) {
+ if (nl[i].href)
+ baseHREF = nl[i].href;
+ }
+
for (var i=0; i<elements.length; i++) {
if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_dev.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) {
var src = elements[i].src;
@@ -71,7 +92,12 @@ TinyMCE_Engine.prototype = {
if (settings.exec_mode == "src" || settings.exec_mode == "normal")
tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : '';
- tinyMCE.baseURL = src;
+ // Force it absolute if page has a base href
+ if (baseHREF != "" && src.indexOf('://') == -1)
+ tinyMCE.baseURL = baseHREF + src;
+ else
+ tinyMCE.baseURL = src;
+
break;
}
}
@@ -100,7 +126,7 @@ TinyMCE_Engine.prototype = {
this._def("textarea_trigger", "mce_editable");
this._def("editor_selector", "");
this._def("editor_deselector", "mceNoEditor");
- this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang]");
+ this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],#td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang],cite[title|id|class|style|dir|lang],abbr[title|id|class|style|dir|lang],acronym[title|id|class|style|dir|lang],del[title|id|class|style|dir|lang|datetime|cite],ins[title|id|class|style|dir|lang|datetime|cite]");
this._def("extended_valid_elements", "");
this._def("invalid_elements", "");
this._def("encoding", "");
@@ -122,6 +148,7 @@ TinyMCE_Engine.prototype = {
this._def("custom_undo_redo_levels", -1);
this._def("custom_undo_redo_keyboard_shortcuts", true);
this._def("custom_undo_redo_restore_selection", true);
+ this._def("custom_undo_redo_global", false);
this._def("verify_html", true);
this._def("apply_source_formatting", false);
this._def("directionality", "ltr");
@@ -164,6 +191,7 @@ TinyMCE_Engine.prototype = {
this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
this._def("hidden_tab_class", '');
this._def("display_tab_class", '');
+ this._def("gecko_spellcheck", false);
// Force strict loading mode to false on non Gecko browsers
if (this.isMSIE && !this.isOpera)
@@ -186,7 +214,7 @@ TinyMCE_Engine.prototype = {
return;
// If not super absolute make it so
- var baseHREF = tinyMCE.settings['document_base_url'];
+ baseHREF = tinyMCE.settings['document_base_url'];
var h = document.location.href;
var p = h.indexOf('://');
if (p > 0 && document.location.protocol != "file:") {
@@ -207,7 +235,10 @@ TinyMCE_Engine.prototype = {
this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
theme = this.settings['theme'];
- this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dt|dd|dir|fieldset|form|noscript|noframes|menu|isindex|samp)$", "i");
+ this.inlineStrict = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';
+ this.inlineTransitional = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';
+ this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
+ this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
@@ -216,7 +247,7 @@ TinyMCE_Engine.prototype = {
// Theme url
this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE || tinyMCE.isOpera)
this.settings['force_br_newlines'] = false;
if (tinyMCE.getParam("popups_css", false)) {
@@ -238,8 +269,10 @@ TinyMCE_Engine.prototype = {
this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
else
this.settings['editor_css'] = cssPath;
- } else
- this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
+ } else {
+ if (this.settings.editor_css != '')
+ this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
+ }
if (tinyMCE.settings['debug']) {
var msg = "Debug: \n";
@@ -255,14 +288,10 @@ TinyMCE_Engine.prototype = {
// Only do this once
if (this.configs.length == 0) {
- // Is Safari enabled
- if (this.isSafari && this.getParam('safari_warning', false))
- alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
-
if (typeof(TinyMCECompressed) == "undefined") {
tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
if (document.body)
tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
else
@@ -288,10 +317,12 @@ TinyMCE_Engine.prototype = {
}
// Setup entities
- settings['cleanup_entities'] = new Array();
- var entities = tinyMCE.getParam('entities', '', true, ',');
- for (var i=0; i<entities.length; i+=2)
- settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
+ if (tinyMCE.getParam('entity_encoding') == 'named') {
+ settings['cleanup_entities'] = new Array();
+ var entities = tinyMCE.getParam('entities', '', true, ',');
+ for (var i=0; i<entities.length; i+=2)
+ settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
+ }
// Save away this config
settings['index'] = this.configs.length;
@@ -299,10 +330,18 @@ TinyMCE_Engine.prototype = {
// Start loading first one in chain
this.loadNextScript();
+
+ // Force flicker free CSS backgrounds in IE
+ if (this.isIE && !this.isOpera) {
+ try {
+ document.execCommand('BackgroundImageCache', false, true);
+ } catch (e) {
+ }
+ }
},
_addUnloadEvents : function() {
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
if (tinyMCE.settings['add_unload_trigger']) {
tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler);
tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler);
@@ -316,7 +355,7 @@ TinyMCE_Engine.prototype = {
_def : function(key, def_val, t) {
var v = tinyMCE.getParam(key, def_val);
- v = t ? v.replace(/\s+/g,"") : v;
+ v = t ? v.replace(/\s+/g, "") : v;
this.settings[key] = v;
},
@@ -409,8 +448,6 @@ TinyMCE_Engine.prototype = {
var x = 0, i = 0, nl, le;
for (x = 0,csslen = ar.length; x<csslen; x++) {
- ignore_css = false;
-
if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) {
/* Make sure it doesn't exist. */
for (i=0, lflen=this.loadedFiles.length; i<lflen; i++) {
@@ -466,7 +503,7 @@ TinyMCE_Engine.prototype = {
},
confirmAdd : function(e, settings) {
- var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
+ var elm = tinyMCE.isIE ? event.srcElement : e.target;
var elementId = elm.name ? elm.name : elm.id;
tinyMCE.settings = settings;
@@ -492,7 +529,7 @@ TinyMCE_Engine.prototype = {
tinyMCE._setHTML(doc, inst.formElement.value);
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE)
doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
}
}
@@ -508,46 +545,62 @@ TinyMCE_Engine.prototype = {
inst._onAdd(replace_element, form_element_name, target_document);
},
+ removeInstance : function(ti) {
+ var t = [], n, i;
+
+ // Remove from instances
+ for (n in tinyMCE.instances) {
+ i = tinyMCE.instances[n];
+
+ if (tinyMCE.isInstance(i) && ti != i)
+ t[n] = i;
+ }
+
+ tinyMCE.instances = t;
+
+ // Remove from global undo/redo
+ n = [];
+ t = tinyMCE.undoLevels;
+
+ for (i=0; i<t.length; i++) {
+ if (t[i] != ti)
+ n.push(t[i]);
+ }
+
+ tinyMCE.undoLevels = n;
+ tinyMCE.undoIndex = n.length;
+
+ return ti;
+ },
+
removeMCEControl : function(editor_id) {
- var inst = tinyMCE.getInstanceById(editor_id);
+ var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn;
if (inst) {
inst.switchSettings();
editor_id = inst.editorId;
- var html = tinyMCE.getContent(editor_id);
+ h = tinyMCE.getContent(editor_id);
- // Remove editor instance from instances array
- var tmpInstances = new Array();
- for (var instanceName in tinyMCE.instances) {
- var instance = tinyMCE.instances[instanceName];
- if (!tinyMCE.isInstance(instance))
- continue;
-
- if (instanceName != editor_id)
- tmpInstances[instanceName] = instance;
- }
- tinyMCE.instances = tmpInstances;
+ this.removeInstance(inst);
tinyMCE.selectedElement = null;
tinyMCE.selectedInstance = null;
// Remove element
- var replaceElement = document.getElementById(editor_id + "_parent");
- var oldTargetElement = inst.oldTargetElement;
- var targetName = oldTargetElement.nodeName.toLowerCase();
-
- if (targetName == "textarea" || targetName == "input") {
- // Just show the old text area
- replaceElement.parentNode.removeChild(replaceElement);
- oldTargetElement.style.display = "inline";
- oldTargetElement.value = html;
+ re = document.getElementById(editor_id + "_parent");
+ ot = inst.oldTargetElement;
+ tn = ot.nodeName.toLowerCase();
+
+ if (tn == "textarea" || tn == "input") {
+ re.parentNode.removeChild(re);
+ ot.style.display = "inline";
+ ot.value = h;
} else {
- oldTargetElement.innerHTML = html;
- oldTargetElement.style.display = 'block';
-
- replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);
- replaceElement.parentNode.removeChild(replaceElement);
+ ot.innerHTML = h;
+ ot.style.display = 'block';
+ re.parentNode.insertBefore(ot, re);
+ re.parentNode.removeChild(re);
}
}
},
@@ -593,52 +646,75 @@ TinyMCE_Engine.prototype = {
},
execInstanceCommand : function(editor_id, command, user_interface, value, focus) {
- var inst = tinyMCE.getInstanceById(editor_id);
+ var inst = tinyMCE.getInstanceById(editor_id), r;
+
if (inst) {
+ r = inst.selection.getRng();
+
if (typeof(focus) == "undefined")
focus = true;
- if (focus)
+ // IE bug lost focus on images in absolute divs Bug #1534575
+ if (focus && (!r || !r.item))
inst.contentWindow.focus();
// Reset design mode if lost
inst.autoResetDesignMode();
this.selectedElement = inst.getFocusElement();
- this.selectedInstance = inst;
+ inst.select();
tinyMCE.execCommand(command, user_interface, value);
// Cancel event so it doesn't call onbeforeonunlaod
- if (tinyMCE.isMSIE && window.event != null)
+ if (tinyMCE.isIE && window.event != null)
tinyMCE.cancelEvent(window.event);
}
},
execCommand : function(command, user_interface, value) {
+ var inst = tinyMCE.selectedInstance;
+
// Default input
user_interface = user_interface ? user_interface : false;
value = value ? value : null;
- if (tinyMCE.selectedInstance)
- tinyMCE.selectedInstance.switchSettings();
+ if (inst)
+ inst.switchSettings();
switch (command) {
- case 'mceHelp':
- tinyMCE.openWindow({
- file : 'about.htm',
- width : 480,
- height : 380
- }, {
- tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
- tinymce_releasedate : tinyMCE.releaseDate,
- inline : "yes"
- });
- return;
+ case "Undo":
+ if (this.getParam('custom_undo_redo_global')) {
+ if (this.undoIndex > 0) {
+ tinyMCE.nextUndoRedoAction = 'Undo';
+ inst = this.undoLevels[--this.undoIndex];
+ inst.select();
+
+ if (!tinyMCE.nextUndoRedoInstanceId)
+ inst.execCommand('Undo');
+ }
+ } else
+ inst.execCommand('Undo');
+ return true;
+
+ case "Redo":
+ if (this.getParam('custom_undo_redo_global')) {
+ if (this.undoIndex <= this.undoLevels.length - 1) {
+ tinyMCE.nextUndoRedoAction = 'Redo';
+ inst = this.undoLevels[this.undoIndex++];
+ inst.select();
+
+ if (!tinyMCE.nextUndoRedoInstanceId)
+ inst.execCommand('Redo');
+ }
+ } else
+ inst.execCommand('Redo');
+
+ return true;
case 'mceFocus':
var inst = tinyMCE.getInstanceById(value);
if (inst)
- inst.contentWindow.focus();
+ inst.getWin().focus();
return;
case "mceAddControl":
@@ -657,7 +733,7 @@ TinyMCE_Engine.prototype = {
case "mceResetDesignMode":
// Resets the designmode state of the editors in Gecko
- if (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
for (var n in tinyMCE.instances) {
if (!tinyMCE.isInstance(tinyMCE.instances[n]))
continue;
@@ -673,8 +749,8 @@ TinyMCE_Engine.prototype = {
return;
}
- if (this.selectedInstance) {
- this.selectedInstance.execCommand(command, user_interface, value);
+ if (inst) {
+ inst.execCommand(command, user_interface, value);
} else if (tinyMCE.settings['focus_alert'])
alert(tinyMCELang['lang_focus_alert']);
},
@@ -696,17 +772,18 @@ TinyMCE_Engine.prototype = {
if (aw.indexOf('%') == -1) {
aw = parseInt(aw);
- aw = aw < 0 ? 300 : aw;
+ aw = (isNaN(aw) || aw < 0) ? 300 : aw;
aw = aw + "px";
}
if (ah.indexOf('%') == -1) {
ah = parseInt(ah);
- ah = ah < 0 ? 240 : ah;
+ ah = (isNaN(ah) || ah < 0) ? 240 : ah;
ah = ah + "px";
}
iframe.setAttribute("id", id);
+ iframe.setAttribute("name", id);
iframe.setAttribute("class", "mceEditorIframe");
iframe.setAttribute("border", "0");
iframe.setAttribute("frameBorder", "0");
@@ -723,7 +800,7 @@ TinyMCE_Engine.prototype = {
iframe.setAttribute("scrolling", "no");
// Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
iframe.setAttribute("src", this.settings['default_document']);
iframe.style.width = aw;
@@ -734,19 +811,19 @@ TinyMCE_Engine.prototype = {
iframe.style.marginBottom = '-5px';
// MSIE 5.0 issue
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
replace_element.outerHTML = iframe.outerHTML;
else
replace_element.parentNode.replaceChild(iframe, replace_element);
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
return win.frames[id];
else
return iframe;
},
setupContent : function(editor_id) {
- var inst = tinyMCE.instances[editor_id];
+ var inst = tinyMCE.instances[editor_id], i;
var doc = inst.getDoc();
var head = doc.getElementsByTagName('head').item(0);
var content = inst.startContent;
@@ -762,7 +839,7 @@ TinyMCE_Engine.prototype = {
inst.switchSettings();
// Not loaded correctly hit it again, Mozilla bug #997860
- if (!tinyMCE.isMSIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
+ if (!tinyMCE.isIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
// This part will remove the designMode status
// Failes first time in Firefox 1.5b2 on Mac
try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}
@@ -786,6 +863,14 @@ TinyMCE_Engine.prototype = {
inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo');
}
+ // BlockFormat shortcuts keys
+ for (i=1; i<=6; i++)
+ inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, '<h' + i + '>');
+
+ inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '<p>');
+ inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '<div>');
+ inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '<address>');
+
// Add default shortcuts for gecko
if (tinyMCE.isGecko) {
inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold');
@@ -795,7 +880,7 @@ TinyMCE_Engine.prototype = {
// Setup span styles
if (tinyMCE.getParam("convert_fonts_to_spans"))
- inst.getDoc().body.setAttribute('id', 'mceSpanFonts');
+ inst.getBody().setAttribute('id', 'mceSpanFonts');
if (tinyMCE.settings['nowrap'])
doc.body.style.whiteSpace = "nowrap";
@@ -804,7 +889,7 @@ TinyMCE_Engine.prototype = {
doc.editorId = editor_id;
// Add on document element in Mozilla
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE)
doc.documentElement.editorId = editor_id;
inst.setBaseHREF(tinyMCE.settings['base_href']);
@@ -823,7 +908,7 @@ TinyMCE_Engine.prototype = {
content = tinyMCE.storeAwayURLs(content);
content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
// Ugly!!!
window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
@@ -837,7 +922,7 @@ TinyMCE_Engine.prototype = {
content = tinyMCE.cleanupHTMLCode(content);
// Fix for bug #958637
- if (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
var contentElement = inst.getDoc().createElement("body");
var doc = inst.getDoc();
@@ -849,15 +934,8 @@ TinyMCE_Engine.prototype = {
if (tinyMCE.settings['cleanup_on_startup'])
tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
- else {
- // Convert all strong/em to b/i
- content = tinyMCE.regexpReplace(content, "<strong", "<b", "gi");
- content = tinyMCE.regexpReplace(content, "<em(/?)>", "<i$1>", "gi");
- content = tinyMCE.regexpReplace(content, "<em ", "<i ", "gi");
- content = tinyMCE.regexpReplace(content, "</strong>", "</b>", "gi");
- content = tinyMCE.regexpReplace(content, "</em>", "</i>", "gi");
+ else
tinyMCE.setInnerHTML(inst.getBody(), content);
- }
tinyMCE.convertAllRelativeURLs(inst.getBody());
} else {
@@ -881,11 +959,11 @@ TinyMCE_Engine.prototype = {
tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
// Re-add design mode on mozilla
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE)
tinyMCE.addEventHandlers(inst);
// Add blur handler
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
@@ -898,7 +976,7 @@ TinyMCE_Engine.prototype = {
}
// Trigger node change, this call locks buttons for tables and so forth
- tinyMCE.selectedInstance = inst;
+ inst.select();
tinyMCE.selectedElement = inst.contentWindow.document.body;
// Call custom DOM cleanup
@@ -917,19 +995,21 @@ TinyMCE_Engine.prototype = {
if (tinyMCE.isGecko) {
// Remove mce_src from textnodes and comments
tinyMCE.selectNodes(inst.getBody(), function(n) {
- if (n.nodeType == 3 || n.nodeType == 8) {
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
- }
+ if (n.nodeType == 3 || n.nodeType == 8)
+ n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
return false;
});
}
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
// Cleanup any mess left from storyAwayURLs
tinyMCE._removeInternal(inst.getBody());
- tinyMCE.selectedInstance = inst;
+ inst.select();
tinyMCE.triggerNodeChange(false, true);
},
@@ -950,42 +1030,14 @@ TinyMCE_Engine.prototype = {
if (tinyMCE.isGecko) {
// Remove mce_src from textnodes and comments
tinyMCE.selectNodes(n, function(n) {
- if (n.nodeType == 3 || n.nodeType == 8) {
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
- }
+ if (n.nodeType == 3 || n.nodeType == 8)
+ n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
return false;
});
}
},
- removeTinyMCEFormElements : function(form_obj) {
- // Check if form is valid
- if (typeof(form_obj) == "undefined" || form_obj == null)
- return;
-
- // If not a form, find the form
- if (form_obj.nodeName != "FORM") {
- if (form_obj.form)
- form_obj = form_obj.form;
- else
- form_obj = tinyMCE.getParentElement(form_obj, "form");
- }
-
- // Still nothing
- if (form_obj == null)
- return;
-
- // Disable all UI form elements that TinyMCE created
- for (var i=0; i<form_obj.elements.length; i++) {
- var elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;
-
- if (elementId.indexOf('mce_editor_') == 0)
- form_obj.elements[i].disabled = true;
- }
- },
-
handleEvent : function(e) {
var inst = tinyMCE.selectedInstance;
@@ -1016,7 +1068,7 @@ TinyMCE_Engine.prototype = {
// Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks
// This logic forces the width/height to be in pixels while the user is drag/dropping
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
var ife = tinyMCE.selectedInstance.iframeElement;
/*if (ife.style.width.indexOf('%') != -1) {
@@ -1034,13 +1086,12 @@ TinyMCE_Engine.prototype = {
return;
case "submit":
- tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target);
tinyMCE.triggerSave();
tinyMCE.isNotDirty = true;
return;
case "reset":
- var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target;
+ var formObj = tinyMCE.isIE ? window.event.srcElement : e.target;
for (var i=0; i<document.forms.length; i++) {
if (document.forms[i] == formObj)
@@ -1054,41 +1105,39 @@ TinyMCE_Engine.prototype = {
return false;
if (e.target.editorId) {
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ tinyMCE.instances[e.target.editorId].select();
} else {
if (e.target.ownerDocument.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.ownerDocument.editorId];
+ tinyMCE.instances[e.target.ownerDocument.editorId].select();
}
if (tinyMCE.selectedInstance)
tinyMCE.selectedInstance.switchSettings();
// Insert P element
- if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
+ if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
// Insert P element instead of BR
if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) {
// Cancel event
tinyMCE.execCommand("mceAddUndoLevel");
- tinyMCE.cancelEvent(e);
- return false;
+ return tinyMCE.cancelEvent(e);
}
}
// Handle backspace
- if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
+ if ((tinyMCE.isGecko && !tinyMCE.isSafari) && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
// Insert P element instead of BR
if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
// Cancel event
tinyMCE.execCommand("mceAddUndoLevel");
- tinyMCE.cancelEvent(e);
- return false;
+ return tinyMCE.cancelEvent(e);
}
}
// Return key pressed
- if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
+ if (tinyMCE.isIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
if (e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ tinyMCE.instances[e.target.editorId].select();
if (tinyMCE.selectedInstance) {
var sel = tinyMCE.selectedInstance.getDoc().selection;
@@ -1132,9 +1181,7 @@ TinyMCE_Engine.prototype = {
return false;
if (e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
- else
- return;
+ tinyMCE.instances[e.target.editorId].select();
if (tinyMCE.selectedInstance)
tinyMCE.selectedInstance.switchSettings();
@@ -1164,11 +1211,11 @@ TinyMCE_Engine.prototype = {
tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance);
// Fix empty elements on return/enter, check where enter occured
- if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)
+ if (tinyMCE.isIE && e.type == "keydown" && e.keyCode == 13)
tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
// Fix empty elements on return/enter
- if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {
+ if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) {
var elm = tinyMCE.enterKeyElement;
if (elm) {
var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
@@ -1194,8 +1241,9 @@ TinyMCE_Engine.prototype = {
}
// MSIE custom key handling
- if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) {
+ if (tinyMCE.isIE && tinyMCE.settings['custom_undo_redo']) {
var keys = new Array(8,46); // Backspace,Delete
+
for (var i=0; i<keys.length; i++) {
if (keys[i] == e.keyCode) {
if (e.type == "keyup")
@@ -1210,9 +1258,15 @@ TinyMCE_Engine.prototype = {
// Handle Undo/Redo when typing content
- // Start typing (non position key)
- if (!posKey && e.type == "keyup")
- tinyMCE.execCommand("mceStartTyping");
+ if (tinyMCE.isGecko) {
+ // Start typing (not a position key or ctrl key, but ctrl+x and ctrl+p is ok)
+ if (!posKey && e.type == "keyup" && !e.ctrlKey || (e.ctrlKey && (e.keyCode == 86 || e.keyCode == 88)))
+ tinyMCE.execCommand("mceStartTyping");
+ } else {
+ // IE seems to be working better with this setting
+ if (!posKey && e.type == "keyup")
+ tinyMCE.execCommand("mceStartTyping");
+ }
// Store undo bookmark
if (e.type == "keydown" && (posKey || e.ctrlKey) && inst)
@@ -1225,13 +1279,14 @@ TinyMCE_Engine.prototype = {
if (posKey && e.type == "keyup")
tinyMCE.triggerNodeChange(false);
- if (tinyMCE.isMSIE && e.ctrlKey)
+ if (tinyMCE.isIE && e.ctrlKey)
window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
break;
case "mousedown":
case "mouseup":
case "click":
+ case "dblclick":
case "focus":
tinyMCE.hideMenus();
@@ -1241,7 +1296,7 @@ TinyMCE_Engine.prototype = {
}
// Check instance event trigged on
- var targetBody = tinyMCE.getParentElement(e.target, "body");
+ var targetBody = tinyMCE.getParentElement(e.target, "html");
for (var instanceName in tinyMCE.instances) {
if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
continue;
@@ -1251,8 +1306,9 @@ TinyMCE_Engine.prototype = {
// Reset design mode if lost (on everything just in case)
inst.autoResetDesignMode();
- if (inst.getBody() == targetBody) {
- tinyMCE.selectedInstance = inst;
+ // Use HTML element since users might click outside of body element
+ if (inst.getBody().parentNode == targetBody) {
+ inst.select();
tinyMCE.selectedElement = e.target;
tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");
@@ -1261,30 +1317,9 @@ TinyMCE_Engine.prototype = {
}
// Add first bookmark location
- if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark)
+ if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark && (e.type == "mouseup" || e.type == "dblclick"))
tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark();
- if (tinyMCE.isSafari) {
- tinyMCE.selectedInstance.lastSafariSelection = tinyMCE.selectedInstance.selection.getBookmark();
- tinyMCE.selectedInstance.lastSafariSelectedElement = tinyMCE.selectedElement;
-
- var lnk = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
-
- // Patch the darned link
- if (lnk && e.type == "mousedown") {
- lnk.setAttribute("mce_real_href", lnk.getAttribute("href"));
- lnk.setAttribute("href", "javascript:void(0);");
- }
-
- // Patch back
- if (lnk && e.type == "click") {
- window.setTimeout(function() {
- lnk.setAttribute("href", lnk.getAttribute("mce_real_href"));
- lnk.removeAttribute("mce_real_href");
- }, 10);
- }
- }
-
// Reset selected node
if (e.type != "focus")
tinyMCE.selectedNode = null;
@@ -1297,7 +1332,7 @@ TinyMCE_Engine.prototype = {
// Just in case
if (!tinyMCE.selectedInstance && e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ tinyMCE.instances[e.target.editorId].select();
return false;
break;
@@ -1305,7 +1340,7 @@ TinyMCE_Engine.prototype = {
},
getButtonHTML : function(id, lang, img, cmd, ui, val) {
- var h = '', m, x;
+ var h = '', m, x, io = '';
cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
@@ -1317,16 +1352,20 @@ TinyMCE_Engine.prototype = {
cmd += ');';
+ // Patch for IE7 bug with hover out not restoring correctly
+ if (tinyMCE.isRealIE)
+ io = 'onmouseover="tinyMCE.lastHover = this;"';
+
// Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
- if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isMSIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
+ if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
// Tiled button
x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
- h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';
+ h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceTiledButton mceButtonNormal" target="_self">';
h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />';
h += '</a>';
} else {
// Normal button
- h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceButtonNormal" target="_self">';
+ h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceButtonNormal" target="_self">';
h += '<img src="' + img + '" title="{$' + lang + '}" />';
h += '</a>';
}
@@ -1334,6 +1373,58 @@ TinyMCE_Engine.prototype = {
return h;
},
+ getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) {
+ var h = '', m, x;
+
+ mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');';
+ cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
+
+ if (typeof(ui) != "undefined" && ui != null)
+ cmd += ',' + ui;
+
+ if (typeof(val) != "undefined" && val != null)
+ cmd += ",'" + val + "'";
+
+ cmd += ');';
+
+ // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
+ if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
+ x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
+
+ if (tinyMCE.isRealIE)
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
+ else
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
+
+ h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceMenuButtonNormal" target="_self">';
+ h += '<img src="{$themeurl}/images/spacer.gif" style="width: 20px; height: 20px; background-position: ' + x + 'px 0" title="{$' + lang + '}" /></a>';
+ h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
+ h += '</a></span>';
+ } else {
+ if (tinyMCE.isRealIE)
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
+ else
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
+
+ h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
+ h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
+ h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
+ h += '</a></span>';
+ }
+
+ return h;
+ },
+
+ _menuButtonEvent : function(e, o) {
+ if (o.className == 'mceMenuButtonFocus')
+ return;
+
+ if (e == 'over')
+ o.className = o.className + ' mceMenuHover';
+ else
+ o.className = o.className.replace(/\s.*$/, '');
+ },
+
addButtonMap : function(m) {
var i, a = m.replace(/\s+/, '').split(',');
@@ -1342,20 +1433,21 @@ TinyMCE_Engine.prototype = {
},
submitPatch : function() {
- tinyMCE.removeTinyMCEFormElements(this);
tinyMCE.triggerSave();
- this.mceOldSubmit();
tinyMCE.isNotDirty = true;
+ this.mceOldSubmit();
},
onLoad : function() {
+ var r;
+
// Wait for everything to be loaded first
if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) {
window.setTimeout('tinyMCE.onLoad();', 1);
return;
}
- if (tinyMCE.isMSIE && !tinyMCE.isOpera && window.event.type == "readystatechange" && document.readyState != "complete")
+ if (tinyMCE.isRealIE && window.event.type == "readystatechange" && document.readyState != "complete")
return true;
if (tinyMCE.isLoaded)
@@ -1363,6 +1455,15 @@ TinyMCE_Engine.prototype = {
tinyMCE.isLoaded = true;
+ // IE produces JS error if TinyMCE is placed in a frame
+ // It seems to have something to do with the selection not beeing
+ // correctly initialized in IE so this hack solves the problem
+ if (tinyMCE.isRealIE && document.body) {
+ r = document.body.createTextRange();
+ r.collapse(true);
+ r.select();
+ }
+
tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad');
for (var c=0; c<tinyMCE.configs.length; c++) {
@@ -1403,7 +1504,7 @@ TinyMCE_Engine.prototype = {
var element = tinyMCE._getElementById(elements[i]);
var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : "";
- if (tinyMCE.getAttrib(element, "class").indexOf(deselector) != -1)
+ if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class")))
continue;
if (trigger == "false")
@@ -1429,13 +1530,13 @@ TinyMCE_Engine.prototype = {
var elm = nodeList.item(i);
var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']);
- if (selector != '' && tinyMCE.getAttrib(elm, "class").indexOf(selector) == -1)
+ if (selector != '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
continue;
if (selector != '')
trigger = selector != "" ? "true" : "";
- if (tinyMCE.getAttrib(elm, "class").indexOf(deselector) != -1)
+ if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
continue;
if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false"))
@@ -1475,7 +1576,7 @@ TinyMCE_Engine.prototype = {
var inst = tinyMCE.getInstanceById(tinyMCE.settings['auto_focus']);
inst.selection.selectNode(inst.getBody(), true, true);
inst.contentWindow.focus();
- }, 10);
+ }, 100);
}
tinyMCE.dispatchCallback(null, 'oninit', 'onInit');
@@ -1527,8 +1628,10 @@ TinyMCE_Engine.prototype = {
entityDecode : function(s) {
var e = document.createElement("div");
+
e.innerHTML = s;
- return e.innerHTML;
+
+ return e.firstChild.nodeValue;
},
addToLang : function(prefix, ar) {
@@ -1550,23 +1653,19 @@ TinyMCE_Engine.prototype = {
var inst = tinyMCE.selectedInstance;
var editorId = inst.editorId;
var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
- var undoIndex = -1;
+ var undoIndex = -1, doc;
var undoLevels = -1;
var anySelection = false;
var selectedText = inst.selection.getSelectedText();
+ if (tinyMCE.settings.auto_resize)
+ inst.resizeToContent();
+
if (setup_content && tinyMCE.isGecko && inst.isHidden())
elm = inst.getBody();
inst.switchSettings();
- if (tinyMCE.settings["auto_resize"]) {
- var doc = inst.getDoc();
-
- inst.iframeElement.style.width = doc.body.offsetWidth + "px";
- inst.iframeElement.style.height = doc.body.offsetHeight + "px";
- }
-
if (tinyMCE.selectedElement)
anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
@@ -1590,6 +1689,11 @@ TinyMCE_Engine.prototype = {
if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")
content = eval(customCleanup + "(type, content, inst);");
+ // Trigger theme cleanup
+ po = tinyMCE.themes[tinyMCE.settings['theme']];
+ if (po && po.cleanup)
+ content = po.cleanup(type, content, inst);
+
// Trigger plugin cleanups
pl = inst.plugins;
for (i=0; i<pl.length; i++) {
@@ -1616,40 +1720,31 @@ TinyMCE_Engine.prototype = {
tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings['language'] + '.js');
},
- importPluginLanguagePack : function(name, valid_languages) {
- var lang = "en", b = tinyMCE.baseURL + '/plugins/' + name;
-
- valid_languages = valid_languages.split(',');
- for (var i=0; i<valid_languages.length; i++) {
- if (tinyMCE.settings['language'] == valid_languages[i])
- lang = tinyMCE.settings['language'];
- }
+ importPluginLanguagePack : function(name) {
+ var b = tinyMCE.baseURL + '/plugins/' + name;
if (this.plugins[name])
b = this.plugins[name].baseURL;
- tinyMCE.loadScript(b + '/langs/' + lang + '.js');
+ tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings['language'] + '.js');
},
applyTemplate : function(h, as) {
- var i, s, ar = h.match(new RegExp('\\{\\$[a-z0-9_]+\\}', 'gi'));
-
- if (ar && ar.length > 0) {
- for (i=ar.length-1; i>=0; i--) {
- s = ar[i].substring(2, ar[i].length-1);
-
- if (s.indexOf('lang_') == 0 && tinyMCELang[s])
- h = tinyMCE.replaceVar(h, s, tinyMCELang[s]);
- else if (as && as[s])
- h = tinyMCE.replaceVar(h, s, as[s]);
- else if (tinyMCE.settings[s])
- h = tinyMCE.replaceVar(h, s, tinyMCE.settings[s]);
- }
- }
+ return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) {
+ if (s.indexOf('lang_') == 0 && tinyMCELang[s])
+ return tinyMCELang[s];
- h = tinyMCE.replaceVar(h, "themeurl", tinyMCE.themeURL);
+ if (as && as[s])
+ return as[s];
- return h;
+ if (tinyMCE.settings[s])
+ return tinyMCE.settings[s];
+
+ if (m == 'themeurl')
+ return tinyMCE.themeURL;
+
+ return m;
+ });
},
replaceVar : function(h, r, v) {
@@ -1672,7 +1767,7 @@ TinyMCE_Engine.prototype = {
height = 200;
// Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isIE)
height += 40;
else
height += 20;
@@ -1711,7 +1806,7 @@ TinyMCE_Engine.prototype = {
win.resizeTo(width, height);
win.focus();
} else {
- if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
+ if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
height += 10;
var features = "resizable:" + resizable
@@ -1823,7 +1918,7 @@ TinyMCE_Engine.prototype = {
if (anchorName != '' && state) {
el.title = anchorName;
- el.className = 'mceItemAnchor';
+ tinyMCE.addCSSClass(el, 'mceItemAnchor');
} else if (anchorName != '' && !state)
el.className = '';
@@ -1870,7 +1965,7 @@ TinyMCE_Engine.prototype = {
*/
fixGeckoBaseHREFBug : function(m, e, h) {
- var nl, i, a, n, xsrc, xhref, el;
+ var xsrc, xhref;
if (tinyMCE.isGecko) {
if (m == 1) {
@@ -1879,38 +1974,40 @@ TinyMCE_Engine.prototype = {
return h;
} else {
- el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');
+ // Why bother if there is no src or href broken
+ if (!new RegExp('(src|href)=', 'g').test(h))
+ return h;
- for (a=0; a<el.length; a++) {
- n = e.getElementsByTagName(el[a]);
+ // Restore src and href that gets messed up by Gecko
+ tinyMCE.selectElements(e, 'A,IMG,SELECT,AREA,IFRAME,BASE,INPUT,SCRIPT,EMBED,OBJECT,LINK', function (n) {
+ xsrc = tinyMCE.getAttrib(n, "mce_tsrc");
+ xhref = tinyMCE.getAttrib(n, "mce_thref");
- for (i=0; i<n.length; i++) {
- xsrc = tinyMCE.getAttrib(n[i], "mce_tsrc");
- xhref = tinyMCE.getAttrib(n[i], "mce_thref");
-
- if (xsrc != "") {
- try {
- n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
- } catch (e) {
- // Ignore, Firefox cast exception if local file wasn't found
- }
-
- n[i].removeAttribute("mce_tsrc");
+ if (xsrc != "") {
+ try {
+ n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
+ } catch (e) {
+ // Ignore, Firefox cast exception if local file wasn't found
}
- if (xhref != "") {
- try {
- n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
- } catch (e) {
- // Ignore, Firefox cast exception if local file wasn't found
- }
+ n.removeAttribute("mce_tsrc");
+ }
- n[i].removeAttribute("mce_thref");
+ if (xhref != "") {
+ try {
+ n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
+ } catch (e) {
+ // Ignore, Firefox cast exception if local file wasn't found
}
+
+ n.removeAttribute("mce_thref");
}
- }
- el = tinyMCE.selectNodes(e, function(n) {
+ return false;
+ });
+
+ // Restore text/comment nodes
+ tinyMCE.selectNodes(e, function(n) {
if (n.nodeType == 3 || n.nodeType == 8) {
n.nodeValue = n.nodeValue.replace(/\smce_tsrc=/gi, " src=");
n.nodeValue = n.nodeValue.replace(/\smce_thref=/gi, " href=");
@@ -1939,7 +2036,7 @@ TinyMCE_Engine.prototype = {
}
// Content duplication bug fix
- if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
+ if (tinyMCE.isIE && tinyMCE.settings['fix_content_duplication']) {
// Remove P elements in P elements
var paras = doc.getElementsByTagName("P");
for (var i=0; i<paras.length; i++) {
@@ -2065,7 +2162,7 @@ TinyMCE_Engine.prototype = {
var csses = null;
// Just ignore any errors
- eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}");
+ eval("try {var csses = tinyMCE.isIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}");
if (!csses)
return new Array();
@@ -2158,7 +2255,7 @@ TinyMCE_Engine.prototype = {
return '';
},
- evalFunc : function(f, idx, a) {
+ evalFunc : function(f, idx, a, o) {
var s = '(', i;
for (i=idx; i<a.length; i++) {
@@ -2170,7 +2267,7 @@ TinyMCE_Engine.prototype = {
s += ');';
- return eval("f" + s);
+ return o ? eval("o." + f + s) : eval("f" + s);
},
dispatchCallback : function(i, p, n) {
@@ -2199,7 +2296,7 @@ TinyMCE_Engine.prototype = {
for (i=0, l = ins.plugins; i<l.length; i++) {
o = tinyMCE.plugins[l[i]];
- if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
+ if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
return true;
}
}
@@ -2208,7 +2305,7 @@ TinyMCE_Engine.prototype = {
for (on in l) {
o = l[on];
- if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
+ if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
return true;
}
@@ -2216,14 +2313,26 @@ TinyMCE_Engine.prototype = {
},
xmlEncode : function(s) {
- s = "" + s;
- s = s.replace(/&/g, '&amp;');
- s = s.replace(new RegExp('"', 'g'), '&quot;');
- s = s.replace(/\'/g, '&#39;'); // &apos; is not working in MSIE
- s = s.replace(/</g, '&lt;');
- s = s.replace(/>/g, '&gt;');
+ return s ? ('' + s).replace(new RegExp('[<>&"\']', 'g'), function (c, b) {
+ switch (c) {
+ case '&':
+ return '&amp;';
- return s;
+ case '"':
+ return '&quot;';
+
+ case '\'':
+ return '&#39;'; // &apos; is not working in MSIE
+
+ case '<':
+ return '&lt;';
+
+ case '>':
+ return '&gt;';
+ }
+
+ return c;
+ }) : s;
},
extend : function(p, np) {
@@ -2252,19 +2361,9 @@ TinyMCE_Engine.prototype = {
tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass);
tinyMCE.lastSelectedMenuBtn = null;
}
- },
-
- explode : function(d, s) {
- var ar = s.split(d), oar = new Array(), i;
-
- for (i = 0; i<ar.length; i++) {
- if (ar[i] != "")
- oar[oar.length] = ar[i];
- }
-
- return oar;
}
-};
+
+ };
// Global instances
var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors
@@ -2289,10 +2388,13 @@ function TinyMCE_Control(settings) {
this.cleanup = new TinyMCE_Cleanup();
this.shortcuts = new Array();
this.hasMouseMoved = false;
+ this.foreColor = this.backColor = "#999999";
+ this.data = {};
this.cleanup.init({
valid_elements : s.valid_elements,
extended_valid_elements : s.extended_valid_elements,
+ valid_child_elements : s.valid_child_elements,
entities : s.entities,
entity_encoding : s.entity_encoding,
debug : s.cleanup_debug,
@@ -2345,6 +2447,21 @@ function TinyMCE_Control(settings) {
};
TinyMCE_Control.prototype = {
+ selection : null,
+
+ settings : null,
+
+ cleanup : null,
+
+ getData : function(na) {
+ var o = this.data[na];
+
+ if (!o)
+ o = this.data[na] = {};
+
+ return o;
+ },
+
hasPlugin : function(n) {
var i;
@@ -2364,12 +2481,14 @@ TinyMCE_Control.prototype = {
},
repaint : function() {
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ var s, b, ex;
+
+ if (tinyMCE.isRealIE)
return;
try {
- var s = this.selection;
- var b = s.getBookmark(true);
+ s = this.selection;
+ b = s.getBookmark(true);
this.getBody().style.display = 'none';
this.getDoc().execCommand('selectall', false, null);
this.getSel().collapseToStart();
@@ -2387,11 +2506,24 @@ TinyMCE_Control.prototype = {
}
},
+ select : function() {
+ var oldInst = tinyMCE.selectedInstance;
+
+ if (oldInst != this) {
+ if (oldInst)
+ oldInst.execCommand('mceEndTyping');
+
+ tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst);
+ tinyMCE.selectedInstance = this;
+ }
+ },
+
getBody : function() {
- return this.getDoc().body;
+ return this.contentBody ? this.contentBody : this.getDoc().body;
},
getDoc : function() {
+// return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ?
return this.contentWindow.document;
},
@@ -2399,9 +2531,34 @@ TinyMCE_Control.prototype = {
return this.contentWindow;
},
+ getContainerWin : function() {
+ return this.containerWindow ? this.containerWindow : window;
+ },
+
+ getViewPort : function() {
+ return tinyMCE.getViewPort(this.getWin());
+ },
+
+ getParentNode : function(n, f) {
+ return tinyMCE.getParentNode(n, f, this.getBody());
+ },
+
+ getParentElement : function(n, na, f) {
+ return tinyMCE.getParentElement(n, na, f, this.getBody());
+ },
+
+ getParentBlockElement : function(n) {
+ return tinyMCE.getParentBlockElement(n, this.getBody());
+ },
+
+ resizeToContent : function() {
+ var d = this.getDoc(), b = d.body, de = d.documentElement;
+
+ this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px';
+ },
+
addShortcut : function(m, k, d, cmd, ui, va) {
- var n = typeof(k) == "number", ie = tinyMCE.isMSIE, c, sc, i;
- var scl = this.shortcuts;
+ var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts;
if (!tinyMCE.getParam('custom_shortcuts'))
return false;
@@ -2440,6 +2597,7 @@ TinyMCE_Control.prototype = {
for (i=0; i<s.length; i++) {
o = s[i];
+
if (o.alt == e.altKey && o.ctrl == e.ctrlKey && (o.keyCode == e.keyCode || o.charCode == e.charCode)) {
if (o.cmd && (e.type == "keydown" || (e.type == "keypress" && !tinyMCE.isOpera)))
tinyMCE.execCommand(o.cmd, o.ui, o.val);
@@ -2454,15 +2612,17 @@ TinyMCE_Control.prototype = {
autoResetDesignMode : function() {
// Add fix for tab/style.display none/block problems in Gecko
- if (!tinyMCE.isMSIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
- eval('try { this.getDoc().designMode = "On"; } catch(e) {}');
+ if (!tinyMCE.isIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
+ eval('try { this.getDoc().designMode = "On"; this.useCSS = false; } catch(e) {}');
},
isHidden : function() {
- if (tinyMCE.isMSIE)
+ var s;
+
+ if (tinyMCE.isIE)
return false;
- var s = this.getSel();
+ s = this.getSel();
// Weird, wheres that cursor selection?
return (!s || !s.rangeCount || s.rangeCount == 0);
@@ -2470,7 +2630,7 @@ TinyMCE_Control.prototype = {
isDirty : function() {
// Is content modified and not in a submit procedure
- return this.startContent != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
+ return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
},
_mergeElements : function(scmd, pa, ch, override) {
@@ -2486,7 +2646,8 @@ TinyMCE_Control.prototype = {
var stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));
var className = tinyMCE.getAttrib(pa, "class");
- className += " " + tinyMCE.getAttrib(ch, "class");
+ // Removed class adding due to bug #1478272
+ className = tinyMCE.getAttrib(ch, "class");
if (override) {
for (var n in st) {
@@ -2526,21 +2687,14 @@ TinyMCE_Control.prototype = {
},
execCommand : function(command, user_interface, value) {
- var doc = this.getDoc();
- var win = this.getWin();
- var focusElm = this.getFocusElement();
+ var doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement();
- // Is non udno specific command
+ // Is not a undo specific command
if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command))
this.undoBookmark = null;
- if (this.lastSafariSelection && !new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) {
- this.selection.moveToBookmark(this.lastSafariSelection);
- tinyMCE.selectedElement = this.lastSafariSelectedElement;
- }
-
// Mozilla issue
- if (!tinyMCE.isMSIE && !this.useCSS) {
+ if (!tinyMCE.isIE && !this.useCSS) {
this._setUseCSS(false);
this.useCSS = true;
}
@@ -2654,24 +2808,39 @@ TinyMCE_Control.prototype = {
this.repaint();
return true;
- case "InsertUnorderedList":
- case "InsertOrderedList":
- var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
+ case "unlink":
+ // Unlink if caret is inside link
+ if (tinyMCE.isGecko && this.getSel().isCollapsed) {
+ focusElm = tinyMCE.getParentElement(focusElm, 'A');
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "<" + tag + "><li>&nbsp;</li><" + tag + ">");
- else
- this.getDoc().execCommand(command, user_interface, value);
+ if (focusElm)
+ this.selection.selectNode(focusElm, false);
+ }
+
+ this.getDoc().execCommand(command, user_interface, value);
+
+ tinyMCE.isGecko && this.getSel().collapseToEnd();
tinyMCE.triggerNodeChange();
+
+ return true;
+
+ case "FormatBlock":
+ if (!this.cleanup.isValid(value))
+ return true;
+
+ this.getDoc().execCommand(command, user_interface, value);
+ tinyMCE.triggerNodeChange();
break;
- case "Strikethrough":
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "<strike>" + this.selection.getSelectedHTML() + "</strike>");
- else
- this.getDoc().execCommand(command, user_interface, value);
+ case "InsertUnorderedList":
+ case "InsertOrderedList":
+ this.getDoc().execCommand(command, user_interface, value);
+ tinyMCE.triggerNodeChange();
+ break;
+ case "Strikethrough":
+ this.getDoc().execCommand(command, user_interface, value);
tinyMCE.triggerNodeChange();
break;
@@ -2691,7 +2860,7 @@ TinyMCE_Control.prototype = {
if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value))
value = value.replace(/[^a-z]/gi, '');
- if (tinyMCE.isMSIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
+ if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
var b = this.selection.getBookmark();
this.getDoc().execCommand("FormatBlock", false, '<p>');
tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value);
@@ -2708,7 +2877,7 @@ TinyMCE_Control.prototype = {
if (!value)
value = tinyMCE.getParentElement(this.getFocusElement());
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
value.outerHTML = value.innerHTML;
} else {
var rng = value.ownerDocument.createRange();
@@ -2759,7 +2928,7 @@ TinyMCE_Control.prototype = {
var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;
// Whole element selected check
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
// Control range
if (rng.item)
parentElm = rng.item(0);
@@ -2953,10 +3122,20 @@ TinyMCE_Control.prototype = {
return;
case "forecolor":
+ value = value == null ? this.foreColor : value;
+ value = tinyMCE.trim(value);
+ value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
+
+ this.foreColor = value;
this.getDoc().execCommand('forecolor', false, value);
break;
case "HiliteColor":
+ value = value == null ? this.backColor : value;
+ value = tinyMCE.trim(value);
+ value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
+ this.backColor = value;
+
if (tinyMCE.isGecko) {
this._setUseCSS(true);
this.getDoc().execCommand('hilitecolor', false, value);
@@ -2994,9 +3173,14 @@ TinyMCE_Control.prototype = {
// Call custom cleanup code
value = tinyMCE.storeAwayURLs(value);
value = tinyMCE._customCleanup(this, "insert_to_editor", value);
- tinyMCE._setHTML(doc, value);
- tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(this, doc, tinyMCE.settings, doc.body));
- tinyMCE.convertAllRelativeURLs(doc.body);
+
+ if (this.getBody().nodeName == 'BODY')
+ tinyMCE._setHTML(doc, value);
+ else
+ this.getBody().innerHTML = value;
+
+ tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, doc, this.settings, this.getBody(), false, false, false, true));
+ tinyMCE.convertAllRelativeURLs(this.getBody());
// Cleanup any mess left from storyAwayURLs
tinyMCE._removeInternal(this.getBody());
@@ -3005,8 +3189,8 @@ TinyMCE_Control.prototype = {
if (tinyMCE.getParam("convert_fonts_to_spans"))
tinyMCE.convertSpansToFonts(doc);
- tinyMCE.handleVisualAid(doc.body, true, this.visualAid, this);
- tinyMCE._setEventsEnabled(doc.body, false);
+ tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
+ tinyMCE._setEventsEnabled(this.getBody(), false);
return true;
case "mceCleanup":
@@ -3035,7 +3219,7 @@ TinyMCE_Control.prototype = {
var selectedText = "";
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
var rng = doc.selection.createRange();
selectedText = rng.text;
} else
@@ -3074,8 +3258,8 @@ TinyMCE_Control.prototype = {
this.execCommand('mceInsertContent', false, key);
// Store away scroll pos
- var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
- var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
+ var scrollX = this.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft;
+ var scrollY = this.getBody().scrollTop + this.getDoc().documentElement.scrollTop;
// Find marker and replace with RAW HTML
var html = this.getBody().innerHTML;
@@ -3095,7 +3279,9 @@ TinyMCE_Control.prototype = {
value = '';
var insertHTMLFailed = false;
- this.getWin().focus();
+
+ // Removed since it produced problems in IE
+ // this.getWin().focus();
if (tinyMCE.isGecko || tinyMCE.isOpera) {
try {
@@ -3131,15 +3317,7 @@ TinyMCE_Control.prototype = {
}
}
- // Ugly hack in Opera due to non working "inserthtml"
- if (tinyMCE.isOpera && insertHTMLFailed) {
- this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);
- var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL);
- ar[0].outerHTML = value;
- return;
- }
-
- if (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
var isHTML = value.indexOf('<') != -1;
var sel = this.getSel();
var rng = this.getRng();
@@ -3200,18 +3378,23 @@ TinyMCE_Control.prototype = {
tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
} else {
- var rng = doc.selection.createRange();
+ var rng = doc.selection.createRange(), tmpRng = null;
var c = value.indexOf('<!--') != -1;
// Fix comment bug, add tag before comments
if (c)
value = tinyMCE.uniqueTag + value;
+ // tmpRng = rng.duplicate(); // Store away range (Fixes Undo bookmark bug in IE)
+
if (rng.item)
rng.item(0).outerHTML = value;
else
rng.pasteHTML(value);
+ //if (tmpRng)
+ // tmpRng.select(); // Restore range (Fixes Undo bookmark bug in IE)
+
// Remove unique tag
if (c) {
var e = this.getDoc().getElementById('mceTMPElement');
@@ -3219,14 +3402,15 @@ TinyMCE_Control.prototype = {
}
}
+ tinyMCE.execCommand("mceAddUndoLevel");
tinyMCE.triggerNodeChange();
break;
case "mceStartTyping":
if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex == -1) {
this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex;
+ tinyMCE.typingUndoIndex = tinyMCE.undoIndex;
this.execCommand('mceAddUndoLevel');
- //tinyMCE.debug("mceStartTyping");
}
break;
@@ -3234,8 +3418,9 @@ TinyMCE_Control.prototype = {
if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex != -1) {
this.execCommand('mceAddUndoLevel');
this.undoRedo.typingUndoIndex = -1;
- //tinyMCE.debug("mceEndTyping");
}
+
+ tinyMCE.typingUndoIndex = -1;
break;
case "mceBeginUndoLevel":
@@ -3281,7 +3466,8 @@ TinyMCE_Control.prototype = {
case "Indent":
this.getDoc().execCommand(command, user_interface, value);
tinyMCE.triggerNodeChange();
- if (tinyMCE.isMSIE) {
+
+ if (tinyMCE.isIE) {
var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");
do {
if (n && n.nodeName == "BLOCKQUOTE") {
@@ -3300,7 +3486,7 @@ TinyMCE_Control.prototype = {
return;
}
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
try {
var rng = doc.selection.createRange();
rng.execCommand("RemoveFormat", false, null);
@@ -3406,21 +3592,30 @@ TinyMCE_Control.prototype = {
this.settings['area_width'] += deltaWidth;
this.settings['area_height'] += deltaHeight;
+ this.settings['width_style'] = "" + this.settings['width'];
+ this.settings['height_style'] = "" + this.settings['height'];
+
// Special % handling
if (("" + this.settings['width']).indexOf('%') != -1)
this.settings['area_width'] = "100%";
+ else
+ this.settings['width_style'] += 'px';
if (("" + this.settings['height']).indexOf('%') != -1)
this.settings['area_height'] = "100%";
+ else
+ this.settings['height_style'] += 'px';
if (("" + replace_element.style.width).indexOf('%') != -1) {
this.settings['width'] = replace_element.style.width;
this.settings['area_width'] = "100%";
+ this.settings['width_style'] = "100%";
}
if (("" + replace_element.style.height).indexOf('%') != -1) {
this.settings['height'] = replace_element.style.height;
this.settings['area_height'] = "100%";
+ this.settings['height_style'] = "100%";
}
html = tinyMCE.applyTemplate(html);
@@ -3489,7 +3684,7 @@ TinyMCE_Control.prototype = {
var dynamicIFrame = false;
var tElm = targetDoc.getElementById(this.editorId);
- if (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
// Node case is preserved in XML strict mode
if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) {
tElm = tinyMCE._createIFrame(tElm, targetDoc);
@@ -3543,7 +3738,7 @@ TinyMCE_Control.prototype = {
// This timeout is needed in MSIE 5.5 for some odd reason
// it seems that the document.frames isn't initialized yet?
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isIE)
window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
tinyMCE.setupContent(this.editorId, true);
@@ -3573,6 +3768,25 @@ TinyMCE_Control.prototype = {
}
},
+ getHTML : function(r) {
+ var h, d = this.getDoc(), b = this.getBody();
+
+ if (r)
+ return b.innerHTML;
+
+ h = tinyMCE._cleanupHTML(this, d, this.settings, b, false, true, false, true);
+
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(d);
+
+ return h;
+ },
+
+ setHTML : function(h) {
+ this.execCommand('mceSetContent', false, h);
+ this.repaint();
+ },
+
getFocusElement : function() {
return this.selection.getFocusElement();
},
@@ -3586,13 +3800,13 @@ TinyMCE_Control.prototype = {
},
triggerSave : function(skip_cleanup, skip_callback) {
- var e, nl = new Array(), i, s;
+ var e, nl = [], i, s;
this.switchSettings();
s = tinyMCE.settings;
// Force hidden tabs visible while serializing
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
e = this.iframeElement;
do {
@@ -3658,7 +3872,8 @@ TinyMCE_Control.prototype = {
nl[i].elm.className = s.hidden_tab_class;
}
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */
@@ -3679,12 +3894,17 @@ TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) {
s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />');
// Weird MSIE bug, <p><hr /></p> breaks runtime?
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isIE)
s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>");
+ // Weird tags will make IE error #bug: 1538495
+ if (tinyMCE.isIE)
+ s = s.replace(/<!(\s*)\/>/g, '');
+
// Convert relative anchors to absolute URLs ex: #something to file.htm#something
- if (tinyMCE.getParam('convert_urls'))
- s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
+ // Removed: Since local document anchors should never be forced absolute example edit.php?id=something
+ //if (tinyMCE.getParam('convert_urls'))
+ // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
return s;
};
@@ -3826,7 +4046,7 @@ TinyMCE_Engine.prototype.convertSpansToFonts = function(doc) {
var h = doc.body.innerHTML;
h = h.replace(/<span/gi, '<font');
h = h.replace(/<\/span/gi, '</font');
- doc.body.innerHTML = h;
+ tinyMCE.setInnerHTML(doc.body, h);
var s = doc.getElementsByTagName("font");
for (var i=0; i<s.length; i++) {
@@ -3865,7 +4085,7 @@ TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) {
var h = doc.body.innerHTML;
h = h.replace(/<font/gi, '<span');
h = h.replace(/<\/font/gi, '</span');
- doc.body.innerHTML = h;
+ tinyMCE.setInnerHTML(doc.body, h);
var fsClasses = tinyMCE.getParam('font_size_classes');
if (fsClasses != '')
@@ -3921,20 +4141,11 @@ TinyMCE_Engine.prototype.cleanupAnchors = function(doc) {
};
TinyMCE_Engine.prototype.getContent = function(editor_id) {
- var h;
-
if (typeof(editor_id) != "undefined")
- tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id);
+ tinyMCE.getInstanceById(editor_id).select();
- if (tinyMCE.selectedInstance) {
- h = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true);
-
- // When editing always use fonts internaly
- if (tinyMCE.getParam("convert_fonts_to_spans"))
- tinyMCE.convertSpansToFonts(this.selectedInstance.getDoc());
-
- return h;
- }
+ if (tinyMCE.selectedInstance)
+ return tinyMCE.selectedInstance.getHTML();
return null;
};
@@ -3986,8 +4197,8 @@ TinyMCE_Engine.prototype._fixTables = function(d) {
}
};
-TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit) {
- var h, d, t1, t2, t3, t4, t5, c, s;
+TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit, inn) {
+ var h, d, t1, t2, t3, t4, t5, c, s, nb;
if (!tinyMCE.getParam('cleanup'))
return elm.innerHTML;
@@ -4025,25 +4236,28 @@ TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual,
c.sourceIndex = -1;
if (s.cleanup_serializer == "xml")
- h = c.serializeNodeAsXML(elm);
+ h = c.serializeNodeAsXML(elm, inn);
else
- h = c.serializeNodeAsHTML(elm);
+ h = c.serializeNodeAsHTML(elm, inn);
if (d)
t3 = new Date().getTime();
// Post processing
+ nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? '&#160;' : '&nbsp;';
h = h.replace(/<\/?(body|head|html)[^>]*>/gi, '');
h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), '');
h = h.replace(/<p><hr \/><\/p>/g, '<hr />');
h = h.replace(/<p>(&nbsp;|&#160;)<\/p><hr \/><p>(&nbsp;|&#160;)<\/p>/g, '<hr />');
- h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>&nbsp;</td>');
- h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>&nbsp;</p>');
- h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*(&nbsp;|&#160;)\s*<\/p>/g, '<p>&nbsp;</p>');
- h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*<\/p>/g, '<p>&nbsp;</p>');
- h = h.replace(/<p>\s*<br \/>\s*&nbsp;\s*<\/p>/g, '<p>&nbsp;</p>');
+ h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>');
+ h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
+ h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko
+ h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko
+ h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*(&nbsp;|&#160;)\s*<\/p>/g, '<p>' + nb + '</p>');
+ h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
+ h = h.replace(/<p>\s*<br \/>\s*&nbsp;\s*<\/p>/g, '<p>' + nb + '</p>');
h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1');
- h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>&nbsp;</p>');
+ h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>');
// Clean body
if (/^\s*(<br \/>|<p>&nbsp;<\/p>|<p>&#160;<\/p>|<p><\/p>)\s*$/.test(h))
@@ -4059,7 +4273,7 @@ TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual,
// Gecko specific processing
if (tinyMCE.isGecko) {
h = h.replace(/<o:p _moz-userdefined="" \/>/g, '');
- h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>&nbsp;</td>');
+ h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>');
}
if (s.force_br_newlines)
@@ -4097,7 +4311,7 @@ TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual,
};
function TinyMCE_Cleanup() {
- this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ this.isIE = (navigator.appName == "Microsoft Internet Explorer");
this.rules = tinyMCE.clearArray(new Array());
// Default config
@@ -4118,7 +4332,7 @@ function TinyMCE_Cleanup() {
this.vElements = tinyMCE.clearArray(new Array());
this.vElementsRe = '';
- this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON|AREA)$/;
+ this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/;
this.codeElementsRe = /^(SCRIPT|STYLE)$/;
this.serializationId = 0;
this.mceAttribs = {
@@ -4144,6 +4358,7 @@ TinyMCE_Cleanup.prototype = {
this.nlBeforeRe = this._arrayToRe(s.newline_before_elements.split(','), 'gi', '<(', ')([^>]*)>');
this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>');
this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>');
+ this.serializedNodes = [];
if (s.invalid_elements != '')
this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$');
@@ -4186,6 +4401,71 @@ TinyMCE_Cleanup.prototype = {
this.vElementsRe = this._arrayToRe(this.vElements, '');
},
+ isValid : function(n) {
+ this._setupRules(); // Will initialize cleanup rules
+
+ // Clean the name up a bit
+ n = n.replace(/[^a-z0-9]+/gi, '').toUpperCase();
+
+ return !tinyMCE.getParam('cleanup') || this.vElementsRe.test(n);
+ },
+
+ addChildRemoveRuleStr : function(s) {
+ var x, y, p, i, t, tn, ta, cl, r;
+
+ if (!s)
+ return;
+
+ ta = s.split(',');
+ for (x=0; x<ta.length; x++) {
+ s = ta[x];
+
+ // Split tag/children
+ p = this.split(/\[|\]/, s);
+ if (p == null || p.length < 1)
+ t = s.toUpperCase();
+ else
+ t = p[0].toUpperCase();
+
+ // Handle all tag names
+ tn = this.split('/', t);
+ for (y=0; y<tn.length; y++) {
+ r = "^(";
+
+ // Build regex
+ cl = this.split(/\|/, p[1]);
+ for (i=0; i<cl.length; i++) {
+ if (cl[i] == '%istrict')
+ r += tinyMCE.inlineStrict;
+ else if (cl[i] == '%itrans')
+ r += tinyMCE.inlineTransitional;
+ else if (cl[i] == '%istrict_na')
+ r += tinyMCE.inlineStrict.substring(2);
+ else if (cl[i] == '%itrans_na')
+ r += tinyMCE.inlineTransitional.substring(2);
+ else if (cl[i] == '%btrans')
+ r += tinyMCE.blockElms;
+ else if (cl[i] == '%strict')
+ r += tinyMCE.blockStrict;
+ else
+ r += (cl[i].charAt(0) != '#' ? cl[i].toUpperCase() : cl[i]);
+
+ r += (i != cl.length - 1 ? '|' : '');
+ }
+
+ r += ')$';
+//tinyMCE.debug(t + "=" + r);
+ if (this.childRules == null)
+ this.childRules = tinyMCE.clearArray(new Array());
+
+ this.childRules[tn[y]] = new RegExp(r);
+
+ if (p.length > 1)
+ this.childRules[tn[y]].wrapTag = p[2];
+ }
+ }
+ },
+
parseRuleStr : function(s) {
var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray(new Array()), dv;
@@ -4233,6 +4513,15 @@ TinyMCE_Cleanup.prototype = {
for (i=0; i<a.length; i++) {
t = a[i];
+ if (t.charAt(0) == '!') {
+ a[i] = t = t.substring(1);
+
+ if (!r.reqAttribsRe)
+ r.reqAttribsRe = '\\s+(' + t;
+ else
+ r.reqAttribsRe += '|' + t;
+ }
+
av = new RegExp('(=|:|<)(.*?)$').exec(t);
t = t.replace(new RegExp('(=|:|<).*?$'), '');
if (av && av.length > 0) {
@@ -4252,7 +4541,7 @@ TinyMCE_Cleanup.prototype = {
if (!r.validAttribValues)
r.validAttribValues = tinyMCE.clearArray(new Array());
- r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), '');
+ r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i');
}
}
@@ -4261,6 +4550,9 @@ TinyMCE_Cleanup.prototype = {
a[i] = t.toLowerCase();
}
+ if (r.reqAttribsRe)
+ r.reqAttribsRe = new RegExp(r.reqAttribsRe + ')=\"', 'g');
+
r.vAttribsRe += ')$';
r.vAttribsRe = this._wildcardToRe(r.vAttribsRe);
r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe);
@@ -4285,7 +4577,7 @@ TinyMCE_Cleanup.prototype = {
var s, b;
if (!this.xmlDoc) {
- if (this.isMSIE) {
+ if (this.isIE) {
try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {}
if (!this.xmlDoc)
@@ -4305,7 +4597,7 @@ TinyMCE_Cleanup.prototype = {
this._convertToXML(n, b);
- if (this.isMSIE)
+ if (this.isIE)
return this.xmlDoc.xml;
else
return new XMLSerializer().serializeToString(this.xmlDoc);
@@ -4356,23 +4648,36 @@ TinyMCE_Cleanup.prototype = {
}
},
- serializeNodeAsHTML : function(n) {
- var en, no, h = '', i, l, r, cn, va = false, f = false, at, hc;
+ serializeNodeAsHTML : function(n, inn) {
+ var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr;
this._setupRules(); // Will initialize cleanup rules
if (this._isDuplicate(n))
return '';
+ // Skip non valid child elements
+ if (n.parentNode && this.childRules != null) {
+ cr = this.childRules[n.parentNode.nodeName];
+
+ if (typeof(cr) != "undefined" && !cr.test(n.nodeName)) {
+ st = true;
+ t = null;
+ }
+ }
+
switch (n.nodeType) {
case 1: // Element
hc = n.hasChildNodes();
+ if (st)
+ break;
+
// MSIE sometimes produces <//tag>
- if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && n.nodeName.indexOf('/') != -1)
+ if ((tinyMCE.isRealIE) && n.nodeName.indexOf('/') != -1)
break;
- if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName))) {
+ if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName)) && !inn) {
va = true;
r = this.rules[n.nodeName];
@@ -4392,7 +4697,7 @@ TinyMCE_Cleanup.prototype = {
if (r.removeEmpty && !hc)
return "";
- h += '<' + en;
+ t = '<' + en;
if (r.vAttribsReIsWild) {
// Serialize wildcard attributes
@@ -4400,12 +4705,12 @@ TinyMCE_Cleanup.prototype = {
for (i=at.length-1; i>-1; i--) {
no = at[i];
if (no.specified && r.vAttribsRe.test(no.nodeName))
- h += this._serializeAttribute(n, r, no.nodeName);
+ t += this._serializeAttribute(n, r, no.nodeName);
}
} else {
// Serialize specific attributes
for (i=r.vAttribs.length-1; i>-1; i--)
- h += this._serializeAttribute(n, r, r.vAttribs[i]);
+ t += this._serializeAttribute(n, r, r.vAttribs[i]);
}
// Serialize mce_ atts
@@ -4414,28 +4719,39 @@ TinyMCE_Cleanup.prototype = {
for (no in at) {
if (at[no])
- h += this._serializeAttribute(n, r, at[no]);
+ t += this._serializeAttribute(n, r, at[no]);
}
}
+ // Check for required attribs
+ if (r.reqAttribsRe && !t.match(r.reqAttribsRe))
+ t = null;
+
// Close these
- if (this.closeElementsRe.test(n.nodeName))
- return h + ' />';
+ if (t != null && this.closeElementsRe.test(n.nodeName))
+ return t + ' />';
- h += '>';
+ if (t != null)
+ h += t + '>';
- if (this.isMSIE && this.codeElementsRe.test(n.nodeName))
+ if (this.isIE && this.codeElementsRe.test(n.nodeName))
h += n.innerHTML;
}
break;
case 3: // Text
+ if (st)
+ break;
+
if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName))
- return this.isMSIE ? '' : n.nodeValue;
+ return this.isIE ? '' : n.nodeValue;
return this.xmlEncode(n.nodeValue);
case 8: // Comment
+ if (st)
+ break;
+
return "<!--" + this._trimComment(n.nodeValue) + "-->";
}
@@ -4451,7 +4767,7 @@ TinyMCE_Cleanup.prototype = {
h += this.fillStr;
// End element
- if (va)
+ if (t != null && va)
h += '</' + en + '>';
return h;
@@ -4488,8 +4804,12 @@ TinyMCE_Cleanup.prototype = {
if (av.length != 0 && av == "{$uid}")
av = "uid_" + (this.idCount++);
- if (av.length != 0)
- return " " + an + "=" + '"' + this.xmlEncode(av) + '"';
+ if (av.length != 0) {
+ if (an.indexOf('on') != 0)
+ av = this.xmlEncode(av);
+
+ return " " + an + "=" + '"' + av + '"';
+ }
return "";
},
@@ -4497,6 +4817,12 @@ TinyMCE_Cleanup.prototype = {
formatHTML : function(h) {
var s = this.settings, p = '', i = 0, li = 0, o = '', l;
+ // Replace BR in pre elements to \n
+ h = h.replace(/<pre([^>]*)>(.*?)<\/pre>/gi, function (a, b, c) {
+ c = c.replace(/<br\s*\/>/gi, '\n');
+ return '<pre' + b + '>' + c + '</pre>';
+ });
+
h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :)
h = '\n' + h;
h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting
@@ -4527,7 +4853,7 @@ TinyMCE_Cleanup.prototype = {
},
xmlEncode : function(s) {
- var i, l, e, o = '', c;
+ var cl = this;
this._setupEntities(); // Will intialize lookup table
@@ -4536,29 +4862,16 @@ TinyMCE_Cleanup.prototype = {
return tinyMCE.xmlEncode(s);
case "named":
- for (i=0, l=s.length; i<l; i++) {
- c = s.charCodeAt(i);
- e = this.entities[c];
+ return s.replace(new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {
+ b = cl.entities[c.charCodeAt(0)];
- if (e && e != '')
- o += '&' + e + ';';
- else
- o += String.fromCharCode(c);
- }
-
- return o;
+ return b ? '&' + b + ';' : c;
+ });
case "numeric":
- for (i=0, l=s.length; i<l; i++) {
- c = s.charCodeAt(i);
-
- if (c > 127 || c == 60 || c == 62 || c == 38 || c == 39 || c == 34)
- o += '&#' + c + ";";
- else
- o += String.fromCharCode(c);
- }
-
- return o;
+ return s.replace(new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {
+ return b ? '&#' + c.charCodeAt(0) + ';' : c;
+ });
}
return s;
@@ -4596,16 +4909,16 @@ TinyMCE_Cleanup.prototype = {
if (n == "class" && !v)
v = e.className;
- if (this.isMSIE && n == "http-equiv")
+ if (this.isIE && n == "http-equiv")
v = e.httpEquiv;
- if (this.isMSIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
+ if (this.isIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
v = "";
- if (this.isMSIE && e.nodeName == "INPUT" && n == "size" && v == "20")
+ if (this.isIE && e.nodeName == "INPUT" && n == "size" && v == "20")
v = "";
- if (this.isMSIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647")
+ if (this.isIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647")
v = "";
if (n == "style" && !tinyMCE.isOpera)
@@ -4679,6 +4992,7 @@ TinyMCE_Cleanup.prototype = {
if (!this.rulesDone) {
this.addRuleStr(s.valid_elements);
this.addRuleStr(s.extended_valid_elements);
+ this.addChildRemoveRuleStr(s.valid_child_elements);
this.rulesDone = true;
}
@@ -4690,7 +5004,7 @@ TinyMCE_Cleanup.prototype = {
if (!this.settings.fix_content_duplication)
return false;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera && n.nodeType == 1) {
+ if (tinyMCE.isRealIE && n.nodeType == 1) {
// Mark elements
if (n.mce_serialized == this.serializationId)
return true;
@@ -4708,10 +5022,44 @@ TinyMCE_Cleanup.prototype = {
return false;
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */
+TinyMCE_Engine.prototype.createTagHTML = function(tn, a, h) {
+ var o = '', f = tinyMCE.xmlEncode;
+
+ o = '<' + tn;
+
+ if (a) {
+ for (n in a) {
+ if (typeof(a[n]) != 'function' && a[n] != null)
+ o += ' ' + f(n) + '="' + f('' + a[n]) + '"';
+ }
+ }
+
+ o += !h ? ' />' : '>' + h + '</' + tn + '>';
+
+ return o;
+};
+
+TinyMCE_Engine.prototype.createTag = function(d, tn, a, h) {
+ var o = d.createElement(tn);
+
+ if (a) {
+ for (n in a) {
+ if (typeof(a[n]) != 'function' && a[n] != null)
+ tinyMCE.setAttrib(o, n, a[n]);
+ }
+ }
+
+ if (h)
+ o.innerHTML = h;
+
+ return o;
+};
+
TinyMCE_Engine.prototype.getElementByAttributeValue = function(n, e, a, v) {
return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0];
};
@@ -4731,13 +5079,10 @@ TinyMCE_Engine.prototype.isBlockElement = function(n) {
return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName);
};
-TinyMCE_Engine.prototype.getParentBlockElement = function(n) {
- while (n) {
- if (this.isBlockElement(n))
- return n;
-
- n = n.parentNode;
- }
+TinyMCE_Engine.prototype.getParentBlockElement = function(n, r) {
+ return this.getParentNode(n, function(n) {
+ return tinyMCE.isBlockElement(n);
+ }, r);
return null;
};
@@ -4752,7 +5097,16 @@ TinyMCE_Engine.prototype.insertAfter = function(n, r){
TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
var i, nl, n;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ // Convert all strong/em to b/i in Gecko
+ if (tinyMCE.isGecko) {
+ h = h.replace(/<strong/gi, '<b');
+ h = h.replace(/<em(\/?)/gi, '<i');
+ h = h.replace(/<em /gi, '<i');
+ h = h.replace(/<\/strong>/gi, '</b>');
+ h = h.replace(/<\/em>/gi, '</i>');
+ }
+
+ if (tinyMCE.isRealIE) {
// Since MSIE handles invalid HTML better that valid XHTML we
// need to make some things invalid. <hr /> gets converted to <hr>.
h = h.replace(/\s\/>/g, '>');
@@ -4782,23 +5136,28 @@ TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
};
TinyMCE_Engine.prototype.getOuterHTML = function(e) {
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isIE)
return e.outerHTML;
var d = e.ownerDocument.createElement("body");
- d.appendChild(e);
+ d.appendChild(e.cloneNode(true));
return d.innerHTML;
};
-TinyMCE_Engine.prototype.setOuterHTML = function(e, h) {
- if (tinyMCE.isMSIE) {
+TinyMCE_Engine.prototype.setOuterHTML = function(e, h, d) {
+ var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t;
+
+ if (tinyMCE.isIE && e.nodeType == 1)
e.outerHTML = h;
- return;
- }
+ else {
+ t = d.createElement("body");
+ t.innerHTML = h;
- var d = e.ownerDocument.createElement("body");
- d.innerHTML = h;
- e.parentNode.replaceChild(d.firstChild, e);
+ for (i=0, nl=t.childNodes; i<nl.length; i++)
+ e.parentNode.insertBefore(nl[i].cloneNode(true), e);
+
+ e.parentNode.removeChild(e);
+ }
};
TinyMCE_Engine.prototype._getElementById = function(id, d) {
@@ -4825,56 +5184,28 @@ TinyMCE_Engine.prototype._getElementById = function(id, d) {
};
TinyMCE_Engine.prototype.getNodeTree = function(n, na, t, nn) {
- var i;
-
- if (typeof(t) == "undefined" || n.nodeType == t && (typeof(nn) == "undefined" || n.nodeName == nn))
- na[na.length] = n;
-
- if (n.hasChildNodes()) {
- for (i=0; i<n.childNodes.length; i++)
- tinyMCE.getNodeTree(n.childNodes[i], na, t, nn);
- }
-
- return na;
+ return this.selectNodes(n, function(n) {
+ return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);
+ }, na ? na : new Array());
};
-TinyMCE_Engine.prototype.getParentElement = function(node, names, attrib_name, attrib_value) {
- if (typeof(names) == "undefined") {
- if (node.nodeType == 1)
- return node;
-
- // Find parent node that is a element
- while ((node = node.parentNode) != null && node.nodeType != 1) ;
+TinyMCE_Engine.prototype.getParentElement = function(n, na, f, r) {
+ var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v;
- return node;
- }
+ // Compatiblity with old scripts where f param was a attribute string
+ if (f && typeof(f) == 'string')
+ return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) != '';});
- if (node == null)
- return null;
-
- var namesAr = names.toUpperCase().split(',');
-
- do {
- for (var i=0; i<namesAr.length; i++) {
- if (node.nodeName == namesAr[i] || names == "*") {
- if (typeof(attrib_name) == "undefined")
- return node;
- else if (node.getAttribute(attrib_name)) {
- if (typeof(attrib_value) == "undefined") {
- if (node.getAttribute(attrib_name) != "")
- return node;
- } else if (node.getAttribute(attrib_name) == attrib_value)
- return node;
- }
- }
- }
- } while ((node = node.parentNode) != null);
-
- return null;
+ return this.getParentNode(n, function(n) {
+ return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n));
+ }, r);
};
-TinyMCE_Engine.prototype.getParentNode = function(n, f) {
+TinyMCE_Engine.prototype.getParentNode = function(n, f, r) {
while (n) {
+ if (n == r)
+ return null;
+
if (f(n))
return n;
@@ -4884,15 +5215,17 @@ TinyMCE_Engine.prototype.getParentNode = function(n, f) {
return null;
};
-TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
- if (typeof(default_value) == "undefined")
- default_value = "";
+TinyMCE_Engine.prototype.getAttrib = function(elm, name, dv) {
+ var v;
+
+ if (typeof(dv) == "undefined")
+ dv = "";
// Not a element
if (!elm || elm.nodeType != 1)
- return default_value;
+ return dv;
- var v = elm.getAttribute(name);
+ v = elm.getAttribute(name);
// Try className for class attrib
if (name == "class" && !v)
@@ -4906,47 +5239,46 @@ TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "")
v = elm.href;
- if (name == "http-equiv" && tinyMCE.isMSIE)
+ if (name == "http-equiv" && tinyMCE.isIE)
v = elm.httpEquiv;
if (name == "style" && !tinyMCE.isOpera)
v = elm.style.cssText;
- return (v && v != "") ? v : default_value;
+ return (v && v != "") ? v : dv;
};
-TinyMCE_Engine.prototype.setAttrib = function(element, name, value, fix_value) {
- if (typeof(value) == "number" && value != null)
- value = "" + value;
+TinyMCE_Engine.prototype.setAttrib = function(el, name, va, fix) {
+ if (typeof(va) == "number" && va != null)
+ va = "" + va;
- if (fix_value) {
- if (value == null)
- value = "";
+ if (fix) {
+ if (va == null)
+ va = "";
- var re = new RegExp('[^0-9%]', 'g');
- value = value.replace(re, '');
+ va = va.replace(/[^0-9%]/g, '');
}
if (name == "style")
- element.style.cssText = value;
+ el.style.cssText = va;
if (name == "class")
- element.className = value;
+ el.className = va;
- if (value != null && value != "" && value != -1)
- element.setAttribute(name, value);
+ if (va != null && va != "" && va != -1)
+ el.setAttribute(name, va);
else
- element.removeAttribute(name);
+ el.removeAttribute(name);
};
-TinyMCE_Engine.prototype.setStyleAttrib = function(elm, name, value) {
- eval('elm.style.' + name + '=value;');
+TinyMCE_Engine.prototype.setStyleAttrib = function(e, n, v) {
+ e.style[n] = v;
- // Style attrib deleted
- if (tinyMCE.isMSIE && value == null || value == '') {
- var str = tinyMCE.serializeStyle(tinyMCE.parseStyle(elm.style.cssText));
- elm.style.cssText = str;
- elm.setAttribute("style", str);
+ // Style attrib deleted in IE
+ if (tinyMCE.isIE && v == null || v == '') {
+ v = tinyMCE.serializeStyle(tinyMCE.parseStyle(e.style.cssText));
+ e.style.cssText = v;
+ e.setAttribute("style", v);
}
};
@@ -4967,16 +5299,16 @@ TinyMCE_Engine.prototype.switchClass = function(ei, c) {
}
};
-TinyMCE_Engine.prototype.getAbsPosition = function(n) {
- var p = {absLeft : 0, absTop : 0};
+TinyMCE_Engine.prototype.getAbsPosition = function(n, cn) {
+ var l = 0, t = 0;
- while (n) {
- p.absLeft += n.offsetLeft;
- p.absTop += n.offsetTop;
+ while (n && n != cn) {
+ l += n.offsetLeft;
+ t += n.offsetTop;
n = n.offsetParent;
}
- return p;
+ return {absLeft : l, absTop : t};
};
TinyMCE_Engine.prototype.prevNode = function(e, n) {
@@ -5005,6 +5337,16 @@ TinyMCE_Engine.prototype.nextNode = function(e, n) {
return null;
};
+TinyMCE_Engine.prototype.selectElements = function(n, na, f) {
+ var i, a = [], nl, x;
+
+ for (x=0, na = na.split(','); x<na.length; x++)
+ for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++)
+ (!f || f(nl[i])) && a.push(nl[i]);
+
+ return a;
+};
+
TinyMCE_Engine.prototype.selectNodes = function(n, f, a) {
var i;
@@ -5024,19 +5366,16 @@ TinyMCE_Engine.prototype.selectNodes = function(n, f, a) {
TinyMCE_Engine.prototype.addCSSClass = function(e, c, b) {
var o = this.removeCSSClass(e, c);
-
return e.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
};
TinyMCE_Engine.prototype.removeCSSClass = function(e, c) {
- var a = this.explode(' ', e.className), i;
-
- for (i=0; i<a.length; i++) {
- if (a[i] == c)
- a[i] = '';
- }
+ c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
+ return e.className = c != ' ' ? c : '';
+};
- return e.className = a.join(' ');
+TinyMCE_Engine.prototype.hasCSSClass = function(n, c) {
+ return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
};
TinyMCE_Engine.prototype.renameElement = function(e, n, d) {
@@ -5061,6 +5400,17 @@ TinyMCE_Engine.prototype.renameElement = function(e, n, d) {
}
};
+TinyMCE_Engine.prototype.getViewPort = function(w) {
+ var d = w.document, m = d.compatMode == 'CSS1Compat', b = d.body, de = d.documentElement;
+
+ return {
+ left : w.pageXOffset || (m ? de.scrollLeft : b.scrollLeft),
+ top : w.pageYOffset || (m ? de.scrollTop : b.scrollTop),
+ width : w.innerWidth || (m ? de.clientWidth : b.clientWidth),
+ height : w.innerHeight || (m ? de.clientHeight : b.clientHeight)
+ };
+};
+
/* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
TinyMCE_Engine.prototype.parseURL = function(url_str) {
@@ -5228,10 +5578,10 @@ TinyMCE_Engine.prototype.convertAbsoluteURLToRelativeURL = function(base_url, ur
};
TinyMCE_Engine.prototype.convertRelativeToAbsoluteURL = function(base_url, relative_url) {
- var baseURL = this.parseURL(base_url);
+ var baseURL = this.parseURL(base_url), baseURLParts, relURLParts;
var relURL = this.parseURL(relative_url);
- if (relative_url == "" || relative_url.charAt(0) == '/' || relative_url.indexOf('://') != -1 || relative_url.indexOf('mailto:') != -1 || relative_url.indexOf('javascript:') != -1)
+ if (relative_url == "" || relative_url.indexOf('://') != -1 || /^(mailto:|javascript:|#|\/)/.test(relative_url))
return relative_url;
// Split parts
@@ -5306,7 +5656,7 @@ TinyMCE_Engine.prototype.convertURL = function(url, node, on_save) {
return url;
// Fix relative/Mozilla
- if (!tinyMCE.isMSIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
+ if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
return tinyMCE.settings['base_href'] + url;
// Handle relative URLs
@@ -5353,12 +5703,14 @@ TinyMCE_Engine.prototype.convertURL = function(url, node, on_save) {
};
TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
+ var i, elms, src, href, mhref, msrc;
+
// Convert all image URL:s to absolute URL
- var elms = body.getElementsByTagName("img");
- for (var i=0; i<elms.length; i++) {
- var src = tinyMCE.getAttrib(elms[i], 'src');
+ elms = body.getElementsByTagName("img");
+ for (i=0; i<elms.length; i++) {
+ src = tinyMCE.getAttrib(elms[i], 'src');
- var msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
+ msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
if (msrc != "")
src = msrc;
@@ -5369,11 +5721,11 @@ TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
}
// Convert all link URL:s to absolute URL
- var elms = body.getElementsByTagName("a");
- for (var i=0; i<elms.length; i++) {
- var href = tinyMCE.getAttrib(elms[i], 'href');
+ elms = body.getElementsByTagName("a");
+ for (i=0; i<elms.length; i++) {
+ href = tinyMCE.getAttrib(elms[i], 'href');
- var mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
+ mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
if (mhref != "")
href = mhref;
@@ -5387,26 +5739,40 @@ TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
/* file:jscripts/tiny_mce/classes/TinyMCE_Array.class.js */
TinyMCE_Engine.prototype.clearArray = function(a) {
- for (var k in a)
- a[k] = null;
+ var n;
+
+ for (n in a)
+ a[n] = null;
return a;
};
+TinyMCE_Engine.prototype.explode = function(d, s) {
+ var ar = s.split(d), oar = new Array(), i;
+
+ for (i = 0; i<ar.length; i++) {
+ if (ar[i] != "")
+ oar[oar.length] = ar[i];
+ }
+
+ return oar;
+};
+
/* file:jscripts/tiny_mce/classes/TinyMCE_Event.class.js */
TinyMCE_Engine.prototype._setEventsEnabled = function(node, state) {
- var events = new Array('onfocus','onblur','onclick','ondblclick',
+ var evs, x, y, elms, i, event;
+ var events = ['onfocus','onblur','onclick','ondblclick',
'onmousedown','onmouseup','onmouseover','onmousemove',
- 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');
+ 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup'];
- var evs = tinyMCE.settings['event_elements'].split(',');
- for (var y=0; y<evs.length; y++){
- var elms = node.getElementsByTagName(evs[y]);
- for (var i=0; i<elms.length; i++) {
- var event = "";
+ evs = tinyMCE.settings['event_elements'].split(',');
+ for (y=0; y<evs.length; y++){
+ elms = node.getElementsByTagName(evs[y]);
+ for (i=0; i<elms.length; i++) {
+ event = "";
- for (var x=0; x<events.length; x++) {
+ for (x=0; x<events.length; x++) {
if ((event = tinyMCE.getAttrib(elms[i], events[x])) != '') {
event = tinyMCE.cleanupEventStr("" + event);
@@ -5453,7 +5819,7 @@ TinyMCE_Engine.prototype._eventPatch = function(editor_id) {
if (!tinyMCE.isInstance(inst))
continue;
- tinyMCE.selectedInstance = inst;
+ inst.select();
win = inst.getWin();
if (win && win.event) {
@@ -5471,38 +5837,64 @@ TinyMCE_Engine.prototype._eventPatch = function(editor_id) {
}
};
+TinyMCE_Engine.prototype.findEvent = function(e) {
+ var n, inst;
+
+ if (e)
+ return e;
+
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
+
+ if (tinyMCE.isInstance(inst) && inst.getWin().event)
+ return inst.getWin().event;
+ }
+
+ return null;
+};
+
TinyMCE_Engine.prototype.unloadHandler = function() {
tinyMCE.triggerSave(true, true);
};
TinyMCE_Engine.prototype.addEventHandlers = function(inst) {
- var doc = inst.getDoc();
+ this.setEventHandlers(inst, 1);
+};
+
+TinyMCE_Engine.prototype.setEventHandlers = function(inst, s) {
+ var doc = inst.getDoc(), ie, ot, i, f = s ? tinyMCE.addEvent : tinyMCE.removeEvent;
+
+ ie = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'controlselect', 'dblclick'];
+ ot = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'focus', 'blur', 'dragdrop'];
inst.switchSettings();
- if (tinyMCE.isMSIE) {
- tinyMCE.addEvent(doc, "keypress", TinyMCE_Engine.prototype._eventPatch);
- tinyMCE.addEvent(doc, "keyup", TinyMCE_Engine.prototype._eventPatch);
- tinyMCE.addEvent(doc, "keydown", TinyMCE_Engine.prototype._eventPatch);
- tinyMCE.addEvent(doc, "mouseup", TinyMCE_Engine.prototype._eventPatch);
- tinyMCE.addEvent(doc, "mousedown", TinyMCE_Engine.prototype._eventPatch);
- tinyMCE.addEvent(doc, "click", TinyMCE_Engine.prototype._eventPatch);
+ if (tinyMCE.isIE) {
+ for (i=0; i<ie.length; i++)
+ f(doc, ie[i], TinyMCE_Engine.prototype._eventPatch);
} else {
- tinyMCE.addEvent(doc, "keypress", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "keydown", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "keyup", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "click", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "mouseup", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "mousedown", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "focus", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "blur", tinyMCE.handleEvent);
+ for (i=0; i<ot.length; i++)
+ f(doc, ot[i], tinyMCE.handleEvent);
eval('try { doc.designMode = "On"; } catch(e) {}'); // Force designmode
}
};
TinyMCE_Engine.prototype.onMouseMove = function() {
- var inst;
+ var inst, lh;
+
+ // Fix for IE7 bug where it's not restoring hover on anchors correctly
+ if (tinyMCE.lastHover) {
+ lh = tinyMCE.lastHover;
+
+ // Call out on menus and refresh class on normal buttons
+ if (lh.className.indexOf('mceMenu') != -1)
+ tinyMCE._menuButtonEvent('out', lh);
+ else
+ lh.className = lh.className;
+
+ tinyMCE.lastHover = null;
+ }
if (!tinyMCE.hasMouseMoved) {
inst = tinyMCE.selectedInstance;
@@ -5519,20 +5911,52 @@ TinyMCE_Engine.prototype.onMouseMove = function() {
};
TinyMCE_Engine.prototype.cancelEvent = function(e) {
- if (tinyMCE.isMSIE) {
+ if (!e)
+ return false;
+
+ if (tinyMCE.isIE) {
e.returnValue = false;
e.cancelBubble = true;
- } else
+ } else {
e.preventDefault();
+ e.stopPropagation && e.stopPropagation();
+ }
+
+ return false;
};
TinyMCE_Engine.prototype.addEvent = function(o, n, h) {
+ // Add cleanup for all non unload events
+ if (n != 'unload') {
+ function clean() {
+ var ex;
+
+ try {
+ tinyMCE.removeEvent(o, n, h);
+ tinyMCE.removeEvent(window, 'unload', clean);
+ o = n = h = null;
+ } catch (ex) {
+ // IE may produce access denied exception on unload
+ }
+ }
+
+ // Add memory cleaner
+ tinyMCE.addEvent(window, 'unload', clean);
+ }
+
if (o.attachEvent)
o.attachEvent("on" + n, h);
else
o.addEventListener(n, h, false);
};
+TinyMCE_Engine.prototype.removeEvent = function(o, n, h) {
+ if (o.detachEvent)
+ o.detachEvent("on" + n, h);
+ else
+ o.removeEventListener(n, h, false);
+};
+
TinyMCE_Engine.prototype.addSelectAccessibility = function(e, s, w) {
// Add event handlers
if (!s._isAccessible) {
@@ -5547,8 +5971,8 @@ TinyMCE_Engine.prototype.addSelectAccessibility = function(e, s, w) {
TinyMCE_Engine.prototype.accessibleEventHandler = function(e) {
var win = this._win;
- e = tinyMCE.isMSIE ? win.event : e;
- var elm = tinyMCE.isMSIE ? e.srcElement : e.target;
+ e = tinyMCE.isIE ? win.event : e;
+ var elm = tinyMCE.isIE ? e.srcElement : e.target;
// Unpiggyback onchange on blur
if (e.type == "blur") {
@@ -5582,7 +6006,7 @@ TinyMCE_Engine.prototype.accessibleEventHandler = function(e) {
TinyMCE_Engine.prototype._resetIframeHeight = function() {
var ife;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
ife = tinyMCE.selectedInstance.iframeElement;
/* if (ife._oldWidth) {
@@ -5608,17 +6032,17 @@ TinyMCE_Selection.prototype = {
var inst = this.instance;
var e, r = this.getRng(), h;
- if (tinyMCE.isSafari) {
- // Not realy perfect!!
- return r.toString();
- }
+ if (!r)
+ return null;
e = document.createElement("body");
- if (tinyMCE.isGecko)
+ if (r.cloneContents)
e.appendChild(r.cloneContents());
- else
+ else if (typeof(r.item) != 'undefined' || typeof(r.htmlText) != 'undefined')
e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
+ else
+ e.innerHTML = r.toString(); // Failed, use text for now
h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false);
@@ -5633,7 +6057,7 @@ TinyMCE_Selection.prototype = {
var inst = this.instance;
var d, r, s, t;
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
d = inst.getDoc();
if (d.selection.type == "Text") {
@@ -5654,29 +6078,23 @@ TinyMCE_Selection.prototype = {
},
getBookmark : function(simple) {
+ var inst = this.instance;
var rng = this.getRng();
- var doc = this.instance.getDoc();
- var sp, le, s, e, nl, i, si, ei;
- var trng, sx, sy, xx = -999999999;
-
- // Skip Opera for now
- if (tinyMCE.isOpera)
- return null;
+ var doc = inst.getDoc(), b = inst.getBody();
+ var sp, le, s, e, nl, i, si, ei, w;
+ var trng, sx, sy, xx = -999999999, vp = inst.getViewPort();
- sx = doc.body.scrollLeft + doc.documentElement.scrollLeft;
- sy = doc.body.scrollTop + doc.documentElement.scrollTop;
+ sx = vp.left;
+ sy = vp.top;
- if (tinyMCE.isSafari || tinyMCE.isGecko)
+ if (tinyMCE.isSafari || tinyMCE.isOpera || simple)
return {rng : rng, scrollX : sx, scrollY : sy};
- if (tinyMCE.isMSIE) {
- if (simple)
- return {rng : rng};
-
+ if (tinyMCE.isIE) {
if (rng.item) {
e = rng.item(0);
- nl = doc.getElementsByTagName(e.nodeName);
+ nl = b.getElementsByTagName(e.nodeName);
for (i=0; i<nl.length; i++) {
if (e == nl[i]) {
sp = i;
@@ -5691,6 +6109,11 @@ TinyMCE_Selection.prototype = {
scrollY : sy
};
} else {
+ trng = doc.body.createTextRange();
+ trng.moveToElementText(inst.getBody());
+ trng.collapse(true);
+ bp = Math.abs(trng.move('character', xx));
+
trng = rng.duplicate();
trng.collapse(true);
sp = Math.abs(trng.move('character', xx));
@@ -5700,7 +6123,7 @@ TinyMCE_Selection.prototype = {
le = Math.abs(trng.move('character', xx)) - sp;
return {
- start : sp,
+ start : sp - bp,
length : le,
scrollX : sx,
scrollY : sy
@@ -5709,51 +6132,64 @@ TinyMCE_Selection.prototype = {
}
if (tinyMCE.isGecko) {
- s = tinyMCE.getParentElement(rng.startContainer);
- for (si=0; si<s.childNodes.length && s.childNodes[si] != rng.startContainer; si++) ;
+ s = this.getSel();
+ e = this.getFocusElement();
- nl = doc.getElementsByTagName(s.nodeName);
- for (i=0; i<nl.length; i++) {
- if (s == nl[i]) {
+ if (!s)
+ return null;
+
+ if (e && e.nodeName == 'IMG') {
+ /*nl = b.getElementsByTagName('IMG');
+ for (i=0; i<nl.length; i++) {
+ if (e == nl[i]) {
sp = i;
break;
}
+ }*/
+
+ return {
+ start : -1,
+ end : -1,
+ index : sp,
+ scrollX : sx,
+ scrollY : sy
+ };
}
- e = tinyMCE.getParentElement(rng.endContainer);
- for (ei=0; ei<e.childNodes.length && e.childNodes[ei] != rng.endContainer; ei++) ;
+ // Caret or selection
+ if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
+ e = this._getPosText(b, s.anchorNode, s.focusNode);
- nl = doc.getElementsByTagName(e.nodeName);
- for (i=0; i<nl.length; i++) {
- if (e == nl[i]) {
- le = i;
- break;
- }
- }
+ if (!e)
+ return {scrollX : sx, scrollY : sy};
- //tinyMCE.debug(s.nodeName, sp, rng.startOffset, '-' , e.nodeName, le, rng.endOffset);
- //tinyMCE.debug(sx, sy);
-
- return {
- startTag : s.nodeName,
- start : sp,
- startIndex : si,
- endTag : e.nodeName,
- end : le,
- endIndex : ei,
- startOffset : rng.startOffset,
- endOffset : rng.endOffset,
- scrollX : sx,
- scrollY : sy
- };
+ return {
+ start : e.start + s.anchorOffset,
+ end : e.end + s.focusOffset,
+ scrollX : sx,
+ scrollY : sy
+ };
+ } else {
+ e = this._getPosText(b, rng.startContainer, rng.endContainer);
+
+ if (!e)
+ return {scrollX : sx, scrollY : sy};
+
+ return {
+ start : e.start + rng.startOffset,
+ end : e.end + rng.endOffset,
+ scrollX : sx,
+ scrollY : sy
+ };
+ }
}
return null;
},
moveToBookmark : function(bookmark) {
- var rng, nl, i;
var inst = this.instance;
+ var rng, nl, i, ex, b = inst.getBody(), sd;
var doc = inst.getDoc();
var win = inst.getWin();
var sel = this.getSel();
@@ -5762,22 +6198,27 @@ TinyMCE_Selection.prototype = {
return false;
if (tinyMCE.isSafari) {
- sel.setBaseAndExtent(bookmark.startContainer, bookmark.startOffset, bookmark.endContainer, bookmark.endOffset);
+ sel.setBaseAndExtent(bookmark.rng.startContainer, bookmark.rng.startOffset, bookmark.rng.endContainer, bookmark.rng.endOffset);
return true;
}
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isRealIE) {
if (bookmark.rng) {
- bookmark.rng.select();
+ try {
+ bookmark.rng.select();
+ } catch (ex) {
+ // Ignore
+ }
+
return true;
}
win.focus();
if (bookmark.tag) {
- rng = inst.getBody().createControlRange();
+ rng = b.createControlRange();
- nl = doc.getElementsByTagName(bookmark.tag);
+ nl = b.getElementsByTagName(bookmark.tag);
if (nl.length > bookmark.index) {
try {
@@ -5787,11 +6228,20 @@ TinyMCE_Selection.prototype = {
}
}
} else {
- rng = inst.getSel().createRange();
- rng.moveToElementText(inst.getBody());
- rng.collapse(true);
- rng.moveStart('character', bookmark.start);
- rng.moveEnd('character', bookmark.length);
+ // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
+ try {
+ // Incorrect bookmark
+ if (bookmark.start < 0)
+ return true;
+
+ rng = inst.getSel().createRange();
+ rng.moveToElementText(inst.getBody());
+ rng.collapse(true);
+ rng.moveStart('character', bookmark.start);
+ rng.moveEnd('character', bookmark.length);
+ } catch (ex) {
+ return true;
+ }
}
rng.select();
@@ -5800,36 +6250,83 @@ TinyMCE_Selection.prototype = {
return true;
}
- if (tinyMCE.isGecko && bookmark.rng) {
- sel.removeAllRanges();
- sel.addRange(bookmark.rng);
+ if (tinyMCE.isGecko || tinyMCE.isOpera) {
+ if (bookmark.rng) {
+ sel.removeAllRanges();
+ sel.addRange(bookmark.rng);
+ }
+
+ if (bookmark.start != -1 && bookmark.end != -1) {
+ try {
+ sd = this._getTextPos(b, bookmark.start, bookmark.end);
+ rng = doc.createRange();
+ rng.setStart(sd.startNode, sd.startOffset);
+ rng.setEnd(sd.endNode, sd.endOffset);
+ sel.removeAllRanges();
+ sel.addRange(rng);
+ win.focus();
+ } catch (ex) {
+ // Ignore
+ }
+ }
+
+ /*
+ if (typeof(bookmark.index) != 'undefined') {
+ tinyMCE.selectElements(b, 'IMG', function (n) {
+ if (bookmark.index-- == 0) {
+ // Select image in Gecko here
+ }
+
+ return false;
+ });
+ }
+ */
+
win.scrollTo(bookmark.scrollX, bookmark.scrollY);
return true;
}
- if (tinyMCE.isGecko) {
- // try {
- rng = doc.createRange();
+ return false;
+ },
- nl = doc.getElementsByTagName(bookmark.startTag);
- if (nl.length > bookmark.start)
- rng.setStart(nl[bookmark.start].childNodes[bookmark.startIndex], bookmark.startOffset);
+ _getPosText : function(r, sn, en) {
+ var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
- nl = doc.getElementsByTagName(bookmark.endTag);
- if (nl.length > bookmark.end)
- rng.setEnd(nl[bookmark.end].childNodes[bookmark.endIndex], bookmark.endOffset);
+ while ((n = w.nextNode()) != null) {
+ if (n == sn)
+ d.start = p;
- sel.removeAllRanges();
- sel.addRange(rng);
- /* } catch {
- // Ignore
- }*/
+ if (n == en) {
+ d.end = p;
+ return d;
+ }
- win.scrollTo(bookmark.scrollX, bookmark.scrollY);
- return true;
+ p += n.nodeValue ? n.nodeValue.length : 0;
}
- return false;
+ return null;
+ },
+
+ _getTextPos : function(r, sp, ep) {
+ var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
+
+ while ((n = w.nextNode()) != null) {
+ p += n.nodeValue ? n.nodeValue.length : 0;
+
+ if (p >= sp && !d.startNode) {
+ d.startNode = n;
+ d.startOffset = sp - (p - n.nodeValue.length);
+ }
+
+ if (p >= ep) {
+ d.endNode = n;
+ d.endOffset = ep - (p - n.nodeValue.length);
+
+ return d;
+ }
+ }
+
+ return null;
},
selectNode : function(node, collapse, select_text_node, to_start) {
@@ -5847,8 +6344,11 @@ TinyMCE_Selection.prototype = {
if (typeof(to_start) == "undefined")
to_start = true;
- if (tinyMCE.isMSIE) {
- rng = inst.getBody().createTextRange();
+ if (inst.settings.auto_resize)
+ inst.resizeToContent();
+
+ if (tinyMCE.isRealIE) {
+ rng = inst.getDoc().body.createTextRange();
try {
rng.moveToElementText(node);
@@ -5915,69 +6415,79 @@ TinyMCE_Selection.prototype = {
},
scrollToNode : function(node) {
- var inst = this.instance;
- var pos, doc, scrollX, scrollY, height;
-
- // Scroll to node position
- pos = tinyMCE.getAbsPosition(node);
- doc = inst.getDoc();
- scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;
- scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;
- height = tinyMCE.isMSIE ? document.getElementById(inst.editorId).style.pixelHeight : inst.targetElement.clientHeight;
+ var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin;
// Only scroll if out of visible area
- if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))
- inst.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);
+ if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25))
+ w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25);
+
+ // Scroll container window
+ if (inst.settings.auto_resize) {
+ cwin = inst.getContainerWin();
+ cvp = tinyMCE.getViewPort(cwin);
+ p = this.getAbsPosition(node);
+
+ if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height)
+ cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25);
+ }
+ },
+
+ getAbsPosition : function(n) {
+ var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement);
+
+ return {
+ absLeft : ipos.absLeft + pos.absLeft,
+ absTop : ipos.absTop + pos.absTop
+ };
},
getSel : function() {
var inst = this.instance;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
return inst.getDoc().selection;
return inst.contentWindow.getSelection();
},
getRng : function() {
- var inst = this.instance;
- var sel = this.getSel();
+ var s = this.getSel();
- if (sel == null)
+ if (s == null)
return null;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- return sel.createRange();
+ if (tinyMCE.isRealIE)
+ return s.createRange();
- if (tinyMCE.isSafari && !sel.getRangeAt)
+ if (tinyMCE.isSafari && !s.getRangeAt)
return '' + window.getSelection();
- return sel.getRangeAt(0);
+ return s.getRangeAt(0);
},
getFocusElement : function() {
- var inst = this.instance;
+ var inst = this.instance, doc, rng, sel, elm;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
- var doc = inst.getDoc();
- var rng = doc.selection.createRange();
+ if (tinyMCE.isRealIE) {
+ doc = inst.getDoc();
+ rng = doc.selection.createRange();
// if (rng.collapse)
// rng.collapse(true);
- var elm = rng.item ? rng.item(0) : rng.parentElement();
+ elm = rng.item ? rng.item(0) : rng.parentElement();
} else {
- if (inst.isHidden())
+ if (!tinyMCE.isSafari && inst.isHidden())
return inst.getBody();
- var sel = this.getSel();
- var rng = this.getRng();
+ sel = this.getSel();
+ rng = this.getRng();
if (!sel || !rng)
return null;
- var elm = rng.commonAncestorContainer;
- //var elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
+ elm = rng.commonAncestorContainer;
+ //elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
// Handle selection a image or other control like element such as anchors
if (!rng.collapsed) {
@@ -5999,7 +6509,8 @@ TinyMCE_Selection.prototype = {
return elm;
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */
@@ -6013,39 +6524,40 @@ function TinyMCE_UndoRedo(inst) {
TinyMCE_UndoRedo.prototype = {
add : function(l) {
- var b;
+ var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur;
if (l) {
this.undoLevels[this.undoLevels.length] = l;
return true;
}
- var inst = this.instance;
-
if (this.typingUndoIndex != -1) {
this.undoIndex = this.typingUndoIndex;
- // tinyMCE.debug("Override: " + this.undoIndex);
+
+ if (tinyMCE.typingUndoIndex != -1)
+ tinyMCE.undoIndex = tinyMCE.typingUndoIndex;
}
- var newHTML = tinyMCE.trim(inst.getBody().innerHTML);
+ newHTML = tinyMCE.trim(inst.getBody().innerHTML);
if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) {
- //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex]);
+ //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content);
tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst);
// Time to compress
- var customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
+ customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {
- for (var i=0; i<this.undoLevels.length-1; i++) {
- //tinyMCE.debug(this.undoLevels[i] + "=" + this.undoLevels[i+1]);
+ for (i=0; i<this.undoLevels.length-1; i++)
this.undoLevels[i] = this.undoLevels[i+1];
- }
this.undoLevels.length--;
this.undoIndex--;
+
+ // Todo: Implement global undo/redo logic here
}
b = inst.undoBookmark;
+
if (!b)
b = inst.selection.getBookmark();
@@ -6055,12 +6567,24 @@ TinyMCE_UndoRedo.prototype = {
bookmark : b
};
+ // Remove all above from global undo/redo
+ ul = tinyMCE.undoLevels;
+ for (i=tinyMCE.undoIndex + 1; i<ul.length; i++) {
+ ur = ul[i].undoRedo;
+
+ if (ur.undoIndex == ur.undoLevels.length -1)
+ ur.undoIndex--;
+
+ ur.undoLevels.length--;
+ }
+
+ // Add global undo level
+ tinyMCE.undoLevels[tinyMCE.undoIndex++] = inst;
+ tinyMCE.undoLevels.length = tinyMCE.undoIndex;
+
this.undoLevels.length = this.undoIndex + 1;
- //tinyMCE.debug("level added" + this.undoIndex);
return true;
-
- // tinyMCE.debug(this.undoIndex + "," + (this.undoLevels.length-1));
}
return false;
@@ -6072,13 +6596,13 @@ TinyMCE_UndoRedo.prototype = {
// Do undo
if (this.undoIndex > 0) {
this.undoIndex--;
+
tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
inst.repaint();
+
if (inst.settings.custom_undo_redo_restore_selection)
inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
}
-
- // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
},
redo : function() {
@@ -6088,23 +6612,28 @@ TinyMCE_UndoRedo.prototype = {
if (this.undoIndex < (this.undoLevels.length-1)) {
this.undoIndex++;
+
tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
inst.repaint();
-// if (this.undoIndex > 0)
-// inst.selection.moveToBookmark(this.undoLevels[this.undoIndex-1].bookmark);
+
if (inst.settings.custom_undo_redo_restore_selection)
inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
- // tinyMCE.debug("Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
}
tinyMCE.triggerNodeChange();
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */
var TinyMCE_ForceParagraphs = {
_insertPara : function(inst, e) {
+ var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0);
+ var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock;
+ var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null;
+ var paraBefore, paraAfter, startChop, endChop, contents;
+
function isEmpty(para) {
function isEmptyHTML(html) {
return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";
@@ -6133,43 +6662,33 @@ var TinyMCE_ForceParagraphs = {
return true;
}
- var doc = inst.getDoc();
- var sel = inst.getSel();
- var win = inst.contentWindow;
- var rng = sel.getRangeAt(0);
- var body = doc.body;
- var rootElm = doc.documentElement;
- var blockName = "P";
-
// tinyMCE.debug(body.innerHTML);
// debug(e.target, sel.anchorNode.nodeName, sel.focusNode.nodeName, rng.startContainer, rng.endContainer, rng.commonAncestorContainer, sel.anchorOffset, sel.focusOffset, rng.toString());
// Setup before range
- var rngBefore = doc.createRange();
+ rngBefore = doc.createRange();
rngBefore.setStart(sel.anchorNode, sel.anchorOffset);
rngBefore.collapse(true);
// Setup after range
- var rngAfter = doc.createRange();
+ rngAfter = doc.createRange();
rngAfter.setStart(sel.focusNode, sel.focusOffset);
rngAfter.collapse(true);
// Setup start/end points
- var direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
- var startNode = direct ? sel.anchorNode : sel.focusNode;
- var startOffset = direct ? sel.anchorOffset : sel.focusOffset;
- var endNode = direct ? sel.focusNode : sel.anchorNode;
- var endOffset = direct ? sel.focusOffset : sel.anchorOffset;
+ direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
+ startNode = direct ? sel.anchorNode : sel.focusNode;
+ startOffset = direct ? sel.anchorOffset : sel.focusOffset;
+ endNode = direct ? sel.focusNode : sel.anchorNode;
+ endOffset = direct ? sel.focusOffset : sel.anchorOffset;
startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode;
endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode;
- // tinyMCE.debug(startNode, endNode);
-
// Get block elements
- var startBlock = tinyMCE.getParentBlockElement(startNode);
- var endBlock = tinyMCE.getParentBlockElement(endNode);
+ startBlock = inst.getParentBlockElement(startNode);
+ endBlock = inst.getParentBlockElement(endNode);
// If absolute force paragraph generation within
if (startBlock && new RegExp('absolute|relative|static', 'gi').test(startBlock.style.position))
@@ -6188,7 +6707,7 @@ var TinyMCE_ForceParagraphs = {
}
// Within a list use normal behaviour
- if (tinyMCE.getParentElement(startBlock, "OL,UL") != null)
+ if (tinyMCE.getParentElement(startBlock, "OL,UL", null, body) != null)
return false;
// Within a table create new paragraphs
@@ -6196,16 +6715,16 @@ var TinyMCE_ForceParagraphs = {
startBlock = endBlock = null;
// Setup new paragraphs
- var paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
- var paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
+ paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
+ paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
// Is header, then force paragraph under
if (/^(H[1-6])$/.test(blockName))
paraAfter = doc.createElement("p");
// Setup chop nodes
- var startChop = startNode;
- var endChop = endNode;
+ startChop = startNode;
+ endChop = endNode;
// Get startChop node
node = startChop;
@@ -6236,7 +6755,9 @@ var TinyMCE_ForceParagraphs = {
if (startBlock == null) {
// Delete selection
rng.deleteContents();
- sel.removeAllRanges();
+
+ if (!tinyMCE.isSafari)
+ sel.removeAllRanges();
if (startChop != rootElm && endChop != rootElm) {
// Insert paragraph before
@@ -6260,7 +6781,7 @@ var TinyMCE_ForceParagraphs = {
if (endChop.nodeName != "#text" && endChop.nodeName != "BODY")
rngBefore.setEndAfter(endChop);
- var contents = rng.cloneContents();
+ contents = rng.cloneContents();
if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))
paraAfter.innerHTML = contents.firstChild.innerHTML;
else
@@ -6280,17 +6801,25 @@ var TinyMCE_ForceParagraphs = {
rngBefore.deleteContents();
// Insert new paragraphs
- paraAfter.normalize();
- rngBefore.insertNode(paraAfter);
- paraBefore.normalize();
- rngBefore.insertNode(paraBefore);
+ if (tinyMCE.isOpera) {
+ paraBefore.normalize();
+ rngBefore.insertNode(paraBefore);
+ paraAfter.normalize();
+ rngBefore.insertNode(paraAfter);
+ } else {
+ paraAfter.normalize();
+ rngBefore.insertNode(paraAfter);
+ paraBefore.normalize();
+ rngBefore.insertNode(paraBefore);
+ }
- // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
+ //tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
} else {
body.innerHTML = "<" + blockName + ">&nbsp;</" + blockName + "><" + blockName + ">&nbsp;</" + blockName + ">";
paraAfter = body.childNodes[1];
}
+ inst.selection.moveToBookmark(b);
inst.selection.selectNode(paraAfter, true, true);
return true;
@@ -6308,7 +6837,7 @@ var TinyMCE_ForceParagraphs = {
// Place secound part within new paragraph
rngAfter.setEndAfter(endChop);
rngAfter.setStart(endNode, endOffset);
- var contents = rngAfter.cloneContents();
+ contents = rngAfter.cloneContents();
if (contents.firstChild && contents.firstChild.nodeName == blockName) {
/* var nodes = contents.firstChild.childNodes;
@@ -6331,7 +6860,7 @@ var TinyMCE_ForceParagraphs = {
paraAfter.innerHTML = "&nbsp;";
// Create a range around everything
- var rng = doc.createRange();
+ rng = doc.createRange();
if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {
rng.setStartBefore(startChop.parentNode);
@@ -6349,14 +6878,22 @@ var TinyMCE_ForceParagraphs = {
// Delete all contents and insert new paragraphs
rng.deleteContents();
- rng.insertNode(paraAfter);
- rng.insertNode(paraBefore);
+
+ if (tinyMCE.isOpera) {
+ rng.insertNode(paraBefore);
+ rng.insertNode(paraAfter);
+ } else {
+ rng.insertNode(paraAfter);
+ rng.insertNode(paraBefore);
+ }
+
//tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);
// Normalize
paraAfter.normalize();
paraBefore.normalize();
+ inst.selection.moveToBookmark(b);
inst.selection.selectNode(paraAfter, true, true);
return true;
@@ -6365,21 +6902,26 @@ var TinyMCE_ForceParagraphs = {
_handleBackSpace : function(inst) {
var r = inst.getRng(), sn = r.startContainer, nv, s = false;
- if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR") {
+ // Added body check for bug #1527787
+ if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR" && sn.parentNode.nodeName != "BODY") {
nv = sn.nodeValue;
- // Handle if a backspace is pressed after a space character #bug 1466054
- if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
- s = true;
+ // Handle if a backspace is pressed after a space character #bug 1466054 removed since fix for #1527787
+ /*if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
+ s = true;*/
// Only remove BRs if we are at the end of line #bug 1464152
if (nv != null && r.startOffset == nv.length)
sn.nextSibling.parentNode.removeChild(sn.nextSibling);
}
+ if (inst.settings.auto_resize)
+ inst.resizeToContent();
+
return s;
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */
@@ -6515,14 +7057,20 @@ TinyMCE_Layer.prototype = {
if (!this.blockerElement && this.blockMode) {
d = this.doc;
- b = d.createElement("iframe");
+ b = d.getElementById(this.id + "_blocker");
- b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
- b.src = 'javascript:false;';
- b.frameBorder = '0';
- b.scrolling = 'no';
+ if (!b) {
+ b = d.createElement("iframe");
+
+ b.setAttribute('id', this.id + "_blocker");
+ b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
+ b.src = 'javascript:false;';
+ b.frameBorder = '0';
+ b.scrolling = 'no';
+
+ d.body.appendChild(b);
+ }
- d.body.appendChild(b);
this.blockerElement = b;
}
@@ -6541,7 +7089,7 @@ TinyMCE_Layer.prototype = {
return p;
},
- create : function(n, c, p) {
+ create : function(n, c, p, h) {
var d = this.doc, e = d.createElement(n);
e.setAttribute('id', this.id);
@@ -6552,18 +7100,26 @@ TinyMCE_Layer.prototype = {
if (!p)
p = d.body;
+ if (h)
+ e.innerHTML = h;
+
p.appendChild(e);
return this.element = e;
},
+ exists : function() {
+ return this.doc.getElementById(this.id) != null;
+ },
+
parseInt : function(s) {
if (s == null || s == '')
return 0;
return parseInt(s);
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */
@@ -6582,7 +7138,6 @@ function TinyMCE_Menu() {
this.needsUpdate = true;
};
-// Extends the TinyMCE_Layer class
TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
init : function(s) {
var n;
@@ -6653,7 +7208,7 @@ TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
break;
default:
- h += '<tr><td><a href="javascript:void(0);" onmousedown="' + tinyMCE.xmlEncode(m[i].js) + ';return false;"><span' + c +'>' + t + '</span></a>';
+ h += '<tr><td><a href="#" onclick="return tinyMCE.cancelEvent(event);" onmousedown="return tinyMCE.cancelEvent(event);" onmouseup="' + tinyMCE.xmlEncode(m[i].js) + ';return tinyMCE.cancelEvent(event);"><span' + c +'>' + t + '</span></a>';
}
h += '</td></tr>';
@@ -6690,30 +7245,40 @@ TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
tinyMCE.lastMenu = this;
}
-});
-/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
+ });
-TinyMCE_Engine.prototype.debug = function() {
- var m = "", e, a, i;
+/* file:jscripts/tiny_mce/classes/TinyMCE_Compatibility.class.js */
- e = document.getElementById("tinymce_debug");
- if (!e) {
- var d = document.createElement("div");
- d.setAttribute("className", "debugger");
- d.className = "debugger";
- d.innerHTML = 'Debug output:<textarea id="tinymce_debug" style="width: 100%; height: 300px" wrap="nowrap" mce_editable="false"></textarea>';
+if (!Function.prototype.call) {
+ Function.prototype.call = function() {
+ var a = arguments, s = a[0], i, as = '', r, o;
- document.body.appendChild(d);
- e = document.getElementById("tinymce_debug");
- }
+ for (i=1; i<a.length; i++)
+ as += (i > 1 ? ',' : '') + 'a[' + i + ']';
+
+ o = s._fu;
+ s._fu = this;
+ r = eval('s._fu(' + as + ')');
+ s._fu = o;
- a = this.debug.arguments;
- for (i=0; i<a.length; i++) {
+ return r;
+ };
+};
+
+/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
+
+TinyMCE_Engine.prototype.debug = function() {
+ var m = "", a, i, l = tinyMCE.log.length;
+
+ for (i=0, a = this.debug.arguments; i<a.length; i++) {
m += a[i];
+
if (i<a.length-1)
m += ', ';
}
- e.value += m + "\n";
+ if (l < 1000)
+ tinyMCE.log[l] = "[debug] " + m;
};
+
diff --git a/wp-includes/js/tinymce/tiny_mce_popup.js b/wp-includes/js/tinymce/tiny_mce_popup.js
index cbcdf3e..c4db092 100644
--- a/wp-includes/js/tinymce/tiny_mce_popup.js
+++ b/wp-includes/js/tinymce/tiny_mce_popup.js
@@ -3,274 +3,286 @@
// Some global instances, this will be filled later
var tinyMCE = null, tinyMCELang = null;
-
function TinyMCE_Popup() {
};
+TinyMCE_Popup.prototype = {
+ findWin : function(w) {
+ var c;
-TinyMCE_Popup.prototype.init = function() {
- var win = window.opener ? window.opener : window.dialogArguments;
- var inst;
+ // Check parents
+ c = w;
+ while (c && (c = c.parent) != null) {
+ if (typeof(c.tinyMCE) != "undefined")
+ return c;
+ }
- if (!win) {
- // Try parent
- win = parent.parent;
+ // Check openers
+ c = w;
+ while (c && (c = c.opener) != null) {
+ if (typeof(c.tinyMCE) != "undefined")
+ return c;
+ }
// Try top
- if (typeof(win.tinyMCE) == "undefined")
- win = top;
- }
-
- window.opener = win;
- this.windowOpener = win;
- this.onLoadEval = "";
+ if (typeof(top.tinyMCE) != "undefined")
+ return top;
- // Setup parent references
- tinyMCE = win.tinyMCE;
- tinyMCELang = win.tinyMCELang;
+ return null;
+ },
- if (!tinyMCE) {
- alert("tinyMCE object reference not found from popup.");
- return;
- }
+ init : function() {
+ var win = window.opener ? window.opener : window.dialogArguments, c;
+ var inst;
- inst = tinyMCE.selectedInstance;
- this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
- this.storeSelection = (tinyMCE.isMSIE && !tinyMCE.isOpera) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
+ if (!win)
+ win = this.findWin(window);
- if (this.isWindow)
- window.focus();
+ if (!win) {
+ alert("tinyMCE object reference not found from popup.");
+ return;
+ }
- // Store selection
- if (this.storeSelection)
- inst.selectionBookmark = inst.selection.getBookmark(true);
+ window.opener = win;
+ this.windowOpener = win;
+ this.onLoadEval = "";
- // Setup dir
- if (tinyMCELang['lang_dir'])
- document.dir = tinyMCELang['lang_dir'];
+ // Setup parent references
+ tinyMCE = win.tinyMCE;
+ tinyMCELang = win.tinyMCELang;
- // Setup title
- var re = new RegExp('{|\\\$|}', 'g');
- var title = document.title.replace(re, "");
- if (typeof tinyMCELang[title] != "undefined") {
- var divElm = document.createElement("div");
- divElm.innerHTML = tinyMCELang[title];
- document.title = divElm.innerHTML;
+ inst = tinyMCE.selectedInstance;
+ this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
+ this.storeSelection = (tinyMCE.isRealIE) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
- if (tinyMCE.setWindowTitle != null)
- tinyMCE.setWindowTitle(window, divElm.innerHTML);
- }
+ if (this.isWindow)
+ window.focus();
- // Output Popup CSS class
- document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');
+ // Store selection
+ if (this.storeSelection)
+ inst.selectionBookmark = inst.selection.getBookmark(true);
- tinyMCE.addEvent(window, "load", this.onLoad);
-};
+ // Setup dir
+ if (tinyMCELang['lang_dir'])
+ document.dir = tinyMCELang['lang_dir'];
+ // Setup title
+ var re = new RegExp('{|\\\$|}', 'g');
+ var title = document.title.replace(re, "");
+ if (typeof tinyMCELang[title] != "undefined") {
+ var divElm = document.createElement("div");
+ divElm.innerHTML = tinyMCELang[title];
+ document.title = divElm.innerHTML;
-TinyMCE_Popup.prototype.onLoad = function() {
- var dir, i, elms, body = document.body;
-
- body.onkeydown = function (e) {
- e = e ? e : window.event;
- if ( e.keyCode == 27 && !e.shiftKey && !e.controlKey && !e.altKey ) {
- tinyMCE.closeWindow(window);
+ if (tinyMCE.setWindowTitle != null)
+ tinyMCE.setWindowTitle(window, divElm.innerHTML);
}
- }
- if (tinyMCE.getWindowArg('mce_replacevariables', true))
- body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);
+ // Output Popup CSS class
+ document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');
- dir = tinyMCE.selectedInstance.settings['directionality'];
- if (dir == "rtl" && document.forms && document.forms.length > 0) {
- elms = document.forms[0].elements;
- for (i=0; i<elms.length; i++) {
- if ((elms[i].type == "text" || elms[i].type == "textarea") && elms[i].getAttribute("dir") != "ltr")
- elms[i].dir = dir;
- }
- }
+ if (tinyMCE.getParam("popups_css_add")) {
+ c = tinyMCE.getParam("popups_css_add");
- if (body.style.display == 'none')
- body.style.display = 'block';
+ // Is relative
+ if (c.indexOf('://') == -1 && c.charAt(0) != '/')
+ c = tinyMCE.documentBasePath + "/" + c;
- // Execute real onload (Opera fix)
- if (tinyMCEPopup.onLoadEval != "")
- eval(tinyMCEPopup.onLoadEval);
-};
+ document.write('<link href="' + c + '" rel="stylesheet" type="text/css">');
+ }
+ tinyMCE.addEvent(window, "load", this.onLoad);
+ },
-TinyMCE_Popup.prototype.executeOnLoad = function(str) {
- if (tinyMCE.isOpera)
- this.onLoadEval = str;
- else
- eval(str);
-};
+ onLoad : function() {
+ var dir, i, elms, body = document.body;
+ if (tinyMCE.getWindowArg('mce_replacevariables', true))
+ body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);
-TinyMCE_Popup.prototype.resizeToInnerSize = function() {
- // Netscape 7.1 workaround
- if (this.isWindow && tinyMCE.isNS71) {
- window.resizeBy(0, 10);
- return;
- }
-
- if (this.isWindow) {
- var doc = document;
- var body = doc.body;
- var oldMargin, wrapper, iframe, nodes, dx, dy;
+ dir = tinyMCE.selectedInstance.settings['directionality'];
+ if (dir == "rtl" && document.forms && document.forms.length > 0) {
+ elms = document.forms[0].elements;
+ for (i=0; i<elms.length; i++) {
+ if ((elms[i].type == "text" || elms[i].type == "textarea") && elms[i].getAttribute("dir") != "ltr")
+ elms[i].dir = dir;
+ }
+ }
if (body.style.display == 'none')
body.style.display = 'block';
- // Remove margin
- oldMargin = body.style.margin;
- body.style.margin = '0';
-
- // Create wrapper
- wrapper = doc.createElement("div");
- wrapper.id = 'mcBodyWrapper';
- wrapper.style.display = 'none';
- wrapper.style.margin = '0';
-
- // Wrap body elements
- nodes = doc.body.childNodes;
- for (var i=nodes.length-1; i>=0; i--) {
- if (wrapper.hasChildNodes())
- wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
- else
- wrapper.appendChild(nodes[i].cloneNode(true));
-
- nodes[i].parentNode.removeChild(nodes[i]);
+ // Execute real onload (Opera fix)
+ if (tinyMCEPopup.onLoadEval != "")
+ eval(tinyMCEPopup.onLoadEval);
+ },
+
+ executeOnLoad : function(str) {
+ if (tinyMCE.isOpera)
+ this.onLoadEval = str;
+ else
+ eval(str);
+ },
+
+ resizeToInnerSize : function() {
+ // Netscape 7.1 workaround
+ if (this.isWindow && tinyMCE.isNS71) {
+ window.resizeBy(0, 10);
+ return;
}
- // Add wrapper
- doc.body.appendChild(wrapper);
-
- // Create iframe
- iframe = document.createElement("iframe");
- iframe.id = "mcWinIframe";
- iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
- iframe.width = "100%";
- iframe.height = "100%";
- iframe.style.margin = '0';
-
- // Add iframe
- doc.body.appendChild(iframe);
-
- // Measure iframe
- iframe = document.getElementById('mcWinIframe');
- dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
- dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;
-
- // Resize window
- // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
- window.resizeBy(dx, dy);
-
- // Hide iframe and show wrapper
- body.style.margin = oldMargin;
- iframe.style.display = 'none';
- wrapper.style.display = 'block';
- }
-};
-
-
-TinyMCE_Popup.prototype.resizeToContent = function() {
- var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
- var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
-
- if (isOpera)
- return;
-
- if (isMSIE) {
- try { window.resizeTo(10, 10); } catch (e) {}
-
- var elm = document.body;
- var width = elm.offsetWidth;
- var height = elm.offsetHeight;
- var dx = (elm.scrollWidth - width) + 4;
- var dy = elm.scrollHeight - height;
-
- try { window.resizeBy(dx, dy); } catch (e) {}
- } else {
- window.scrollBy(1000, 1000);
- if (window.scrollX > 0 || window.scrollY > 0) {
- window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
- window.sizeToContent();
- window.scrollTo(0, 0);
- var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
- var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
- window.moveTo(x, y);
+ if (this.isWindow) {
+ var doc = document;
+ var body = doc.body;
+ var oldMargin, wrapper, iframe, nodes, dx, dy;
+
+ if (body.style.display == 'none')
+ body.style.display = 'block';
+
+ // Remove margin
+ oldMargin = body.style.margin;
+ body.style.margin = '0';
+
+ // Create wrapper
+ wrapper = doc.createElement("div");
+ wrapper.id = 'mcBodyWrapper';
+ wrapper.style.display = 'none';
+ wrapper.style.margin = '0';
+
+ // Wrap body elements
+ nodes = doc.body.childNodes;
+ for (var i=nodes.length-1; i>=0; i--) {
+ if (wrapper.hasChildNodes())
+ wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
+ else
+ wrapper.appendChild(nodes[i].cloneNode(true));
+
+ nodes[i].parentNode.removeChild(nodes[i]);
+ }
+
+ // Add wrapper
+ doc.body.appendChild(wrapper);
+
+ // Create iframe
+ iframe = document.createElement("iframe");
+ iframe.id = "mcWinIframe";
+ iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
+ iframe.width = "100%";
+ iframe.height = "100%";
+ iframe.style.margin = '0';
+
+ // Add iframe
+ doc.body.appendChild(iframe);
+
+ // Measure iframe
+ iframe = document.getElementById('mcWinIframe');
+ dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
+ dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;
+
+ // Resize window
+ // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
+ window.resizeBy(dx, dy);
+
+ // Hide iframe and show wrapper
+ body.style.margin = oldMargin;
+ iframe.style.display = 'none';
+ wrapper.style.display = 'block';
}
- }
-};
-
-
-TinyMCE_Popup.prototype.getWindowArg = function(name, default_value) {
- return tinyMCE.getWindowArg(name, default_value);
-};
-
+ },
+
+ resizeToContent : function() {
+ var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
+
+ if (isOpera)
+ return;
+
+ if (isMSIE) {
+ try { window.resizeTo(10, 10); } catch (e) {}
+
+ var elm = document.body;
+ var width = elm.offsetWidth;
+ var height = elm.offsetHeight;
+ var dx = (elm.scrollWidth - width) + 4;
+ var dy = elm.scrollHeight - height;
+
+ try { window.resizeBy(dx, dy); } catch (e) {}
+ } else {
+ window.scrollBy(1000, 1000);
+ if (window.scrollX > 0 || window.scrollY > 0) {
+ window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
+ window.sizeToContent();
+ window.scrollTo(0, 0);
+ var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
+ var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
+ window.moveTo(x, y);
+ }
+ }
+ },
-TinyMCE_Popup.prototype.restoreSelection = function() {
- if (this.storeSelection) {
- var inst = tinyMCE.selectedInstance;
+ getWindowArg : function(name, default_value) {
+ return tinyMCE.getWindowArg(name, default_value);
+ },
- inst.getWin().focus();
+ restoreSelection : function() {
+ if (this.storeSelection) {
+ var inst = tinyMCE.selectedInstance;
- if (inst.selectionBookmark)
- inst.selection.moveToBookmark(inst.selectionBookmark);
- }
-};
+ inst.getWin().focus();
+ if (inst.selectionBookmark)
+ inst.selection.moveToBookmark(inst.selectionBookmark);
+ }
+ },
-TinyMCE_Popup.prototype.execCommand = function(command, user_interface, value) {
- var inst = tinyMCE.selectedInstance;
-
- this.restoreSelection();
- inst.execCommand(command, user_interface, value);
-
- // Store selection
- if (this.storeSelection)
- inst.selectionBookmark = inst.selection.getBookmark(true);
-};
+ execCommand : function(command, user_interface, value) {
+ var inst = tinyMCE.selectedInstance;
+ this.restoreSelection();
+ inst.execCommand(command, user_interface, value);
-TinyMCE_Popup.prototype.close = function() {
- tinyMCE.closeWindow(window);
-};
+ // Store selection
+ if (this.storeSelection)
+ inst.selectionBookmark = inst.selection.getBookmark(true);
+ },
+ close : function() {
+ tinyMCE.closeWindow(window);
+ },
-TinyMCE_Popup.prototype.pickColor = function(e, element_id) {
- tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
- element_id : element_id,
- document : document,
- window : window,
- store_selection : false
- });
-};
+ pickColor : function(e, element_id) {
+ tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
+ element_id : element_id,
+ document : document,
+ window : window,
+ store_selection : false
+ });
+ },
+ openBrowser : function(element_id, type, option) {
+ var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
+ var url = document.getElementById(element_id).value;
-TinyMCE_Popup.prototype.openBrowser = function(element_id, type, option) {
- var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
- var url = document.getElementById(element_id).value;
+ tinyMCE.setWindowArg("window", window);
+ tinyMCE.setWindowArg("document", document);
- tinyMCE.setWindowArg("window", window);
- tinyMCE.setWindowArg("document", document);
+ // Call to external callback
+ if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
+ alert("Callback function: " + cb + " could not be found.");
+ else
+ eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
+ },
- // Call to external callback
- if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
- alert("Callback function: " + cb + " could not be found.");
- else
- eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
-};
+ importClass : function(c) {
+ window[c] = function() {};
-TinyMCE_Popup.prototype.importClass = function(c) {
- window[c] = function() {};
+ for (var n in window.opener[c].prototype)
+ window[c].prototype[n] = window.opener[c].prototype[n];
- for (var n in window.opener[c].prototype)
- window[c].prototype[n] = window.opener[c].prototype[n];
+ window[c].constructor = window.opener[c].constructor;
+ }
- window[c].constructor = window.opener[c].constructor;
-};
+ };
// Setup global instance
var tinyMCEPopup = new TinyMCE_Popup();
diff --git a/wp-includes/js/tinymce/utils/form_utils.js b/wp-includes/js/tinymce/utils/form_utils.js
index 0481815..c502943 100644
--- a/wp-includes/js/tinymce/utils/form_utils.js
+++ b/wp-includes/js/tinymce/utils/form_utils.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: form_utils.js,v $
- * $Revision: 1.10 $
- * $Date: 2006/03/22 12:21:24 $
+ * $Id: form_utils.js 43 2006-08-08 16:10:07Z spocke $
*
* Various form utilitiy functions.
*
@@ -9,18 +7,20 @@
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
+var themeBaseURL = tinyMCE.baseURL + '/themes/' + tinyMCE.getParam("theme");
+
function getColorPickerHTML(id, target_form_element) {
- var html = "";
+ var h = "";
- html += '<a id="' + id + '_link" href="javascript:void(0);" onkeydown="pickColor(event,\'' + target_form_element +'\');" onmousedown="pickColor(event,\'' + target_form_element +'\');return false;">';
- html += '<img id="' + id + '" src="../../themes/' + tinyMCE.getParam("theme") + '/images/color.gif"';
- html += ' onmouseover="this.className=\'mceButtonOver\'"';
- html += ' onmouseout="this.className=\'mceButtonNormal\'"';
- html += ' onmousedown="this.className=\'mceButtonDown\'"';
- html += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
- html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
+ h += '<a id="' + id + '_link" href="javascript:void(0);" onkeydown="pickColor(event,\'' + target_form_element +'\');" onmousedown="pickColor(event,\'' + target_form_element +'\');return false;">';
+ h += '<img id="' + id + '" src="' + themeBaseURL + '/images/color.gif"';
+ h += ' onmouseover="this.className=\'mceButtonOver\'"';
+ h += ' onmouseout="this.className=\'mceButtonNormal\'"';
+ h += ' onmousedown="this.className=\'mceButtonDown\'"';
+ h += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
+ h += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
- return html;
+ return h;
}
function pickColor(e, target_form_element) {
@@ -57,7 +57,7 @@ function getBrowserHTML(id, target_form_element, type, prefix) {
var html = "";
html += '<a id="' + id + '_link" href="javascript:openBrower(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';
- html += '<img id="' + id + '" src="../../themes/' + tinyMCE.getParam("theme") + '/images/browse.gif"';
+ html += '<img id="' + id + '" src="' + themeBaseURL + '/images/browse.gif"';
html += ' onmouseover="this.className=\'mceButtonOver\';"';
html += ' onmouseout="this.className=\'mceButtonNormal\';"';
html += ' onmousedown="this.className=\'mceButtonDown\';"';
@@ -92,9 +92,10 @@ function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
}
if (!found && add_custom && value != '') {
- var option = new Option('Value: ' + value, value);
+ var option = new Option(value, value);
option.selected = true;
sel.options[sel.options.length] = option;
+ sel.selectedIndex = sel.options.length - 1;
}
return found;
diff --git a/wp-includes/js/tinymce/utils/mclayer.js b/wp-includes/js/tinymce/utils/mclayer.js
index 0a7837b..deac8b7 100644
--- a/wp-includes/js/tinymce/utils/mclayer.js
+++ b/wp-includes/js/tinymce/utils/mclayer.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: mclayer.js,v $
- * $Revision: 1.2 $
- * $Date: 2006/02/06 20:11:09 $
+ * $Id: mclayer.js 18 2006-06-29 14:11:23Z spocke $
*
* Moxiecode floating layer script.
*
@@ -209,4 +207,4 @@ MCLayer.prototype = {
return parseInt(s);
}
-} \ No newline at end of file
+}
diff --git a/wp-includes/js/tinymce/utils/mctabs.js b/wp-includes/js/tinymce/utils/mctabs.js
index c159360..354186e 100644
--- a/wp-includes/js/tinymce/utils/mctabs.js
+++ b/wp-includes/js/tinymce/utils/mctabs.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: mctabs.js,v $
- * $Revision: 1.2 $
- * $Date: 2006/02/06 20:11:09 $
+ * $Id: mctabs.js 18 2006-06-29 14:11:23Z spocke $
*
* Moxiecode DHTML Tabs script.
*
diff --git a/wp-includes/js/tinymce/utils/validate.js b/wp-includes/js/tinymce/utils/validate.js
index 747b62b..f329b13 100644
--- a/wp-includes/js/tinymce/utils/validate.js
+++ b/wp-includes/js/tinymce/utils/validate.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: validate.js,v $
- * $Revision: 1.3 $
- * $Date: 2006/02/06 20:11:09 $
+ * $Id: validate.js 65 2006-08-24 15:54:55Z spocke $
*
* Various form validation methods.
*
@@ -9,42 +7,213 @@
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
-function testRegExp(form_name, element_name, re) {
- return new RegExp(re).test(document.forms[form_name].elements[element_name].value);
-}
+/**
+ // String validation:
+
+ if (!Validator.isEmail('myemail'))
+ alert('Invalid email.');
+
+ // Form validation:
+
+ var f = document.forms['myform'];
+
+ if (!Validator.isEmail(f.myemail))
+ alert('Invalid email.');
+*/
+
+var Validator = {
+ isEmail : function(s) {
+ return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
+ },
+
+ isAbsUrl : function(s) {
+ return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
+ },
+
+ isSize : function(s) {
+ return this.test(s, '^[0-9]+(px|%)?$');
+ },
+
+ isId : function(s) {
+ return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
+ },
+
+ isEmpty : function(s) {
+ var nl, i;
+
+ if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
+ return true;
+
+ if (s.type == 'checkbox' && !s.checked)
+ return true;
+
+ if (s.type == 'radio') {
+ for (i=0, nl = s.form.elements; i<nl.length; i++) {
+ if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
+ return false;
+ }
+
+ return true;
+ }
+
+ return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
+ },
+
+ isNumber : function(s, d) {
+ return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
+ },
+
+ test : function(s, p) {
+ s = s.nodeType == 1 ? s.value : s;
+
+ return s == '' || new RegExp(p).test(s);
+ }
+};
+
+var AutoValidator = {
+ settings : {
+ id_cls : 'id',
+ int_cls : 'int',
+ url_cls : 'url',
+ number_cls : 'number',
+ email_cls : 'email',
+ size_cls : 'size',
+ required_cls : 'required',
+ invalid_cls : 'invalid',
+ min_cls : 'min',
+ max_cls : 'max'
+ },
+
+ init : function(s) {
+ var n;
+
+ for (n in s)
+ this.settings[n] = s[n];
+ },
+
+ validate : function(f) {
+ var i, nl, s = this.settings, c = 0;
+
+ nl = this.tags(f, 'label');
+ for (i=0; i<nl.length; i++)
+ this.removeClass(nl[i], s.invalid_cls);
+
+ c += this.validateElms(f, 'input');
+ c += this.validateElms(f, 'select');
+ c += this.validateElms(f, 'textarea');
+
+ return c == 3;
+ },
+
+ invalidate : function(n) {
+ this.mark(n.form, n);
+ },
+
+ reset : function(e) {
+ var t = new Array('label', 'input', 'select', 'textarea');
+ var i, j, nl, s = this.settings;
+
+ if (e == null)
+ return;
+
+ for (i=0; i<t.length; i++) {
+ nl = this.tags(e.form ? e.form : e, t[i]);
+ for (j=0; j<nl.length; j++)
+ this.removeClass(nl[j], s.invalid_cls);
+ }
+ },
+
+ validateElms : function(f, e) {
+ var nl, i, n, s = this.settings, st = true, va = Validator, v;
+
+ nl = this.tags(f, e);
+ for (i=0; i<nl.length; i++) {
+ n = nl[i];
+
+ this.removeClass(n, s.invalid_cls);
+
+ if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.size_cls) && !va.isSize(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.id_cls) && !va.isId(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.min_cls, true)) {
+ v = this.getNum(n, s.min_cls);
+
+ if (isNaN(v) || parseInt(n.value) < parseInt(v))
+ st = this.mark(f, n);
+ }
+
+ if (this.hasClass(n, s.max_cls, true)) {
+ v = this.getNum(n, s.max_cls);
+
+ if (isNaN(v) || parseInt(n.value) > parseInt(v))
+ st = this.mark(f, n);
+ }
+ }
+
+ return st;
+ },
+
+ hasClass : function(n, c, d) {
+ return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
+ },
+
+ getNum : function(n, c) {
+ c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
+ c = c.replace(/[^0-9]/g, '');
+
+ return c;
+ },
-function validateString(form_name, element_name) {
- return (document.forms[form_name].elements[element_name].value.length > 0);
-}
+ addClass : function(n, c, b) {
+ var o = this.removeClass(n, c);
+ n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
+ },
-function validateSelection(form_name, element_name) {
- return (document.forms[form_name].elements[element_name].selectedIndex > 0);
-}
+ removeClass : function(n, c) {
+ c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
+ return n.className = c != ' ' ? c : '';
+ },
-function validateCheckBox(form_name, element_name) {
- return document.forms[form_name].elements[element_name].checked;
-}
+ tags : function(f, s) {
+ return f.getElementsByTagName(s);
+ },
-function validateCleanString(form_name, element_name) {
- return testRegExp(form_name, element_name, '^[A-Za-z0-9_]+$');
-}
+ mark : function(f, n) {
+ var s = this.settings;
-function validateEmail(form_name, element_name) {
- return testRegExp(form_name, element_name, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
-}
+ this.addClass(n, s.invalid_cls);
+ this.markLabels(f, n, s.invalid_cls);
-function validateAbsUrl(form_name, element_name) {
- return testRegExp(form_name, element_name, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+$');
-}
+ return false;
+ },
-function validateNumber(form_name, element_name, allow_blank) {
- return (!allow_blank && value == '') ? false : testRegExp(form_name, element_name, '^-?[0-9]*\\.?[0-9]*$');
-}
+ markLabels : function(f, n, ic) {
+ var nl, i;
-function validateSize(form_name, element_name,) {
- return testRegExp(form_name, element_name, '^[0-9]+(px|%)?$');
-}
+ nl = this.tags(f, "label");
+ for (i=0; i<nl.length; i++) {
+ if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
+ this.addClass(nl[i], ic);
+ }
-function validateID(form_name, element_name,) {
- return testRegExp(form_name, element_name, '^[A-Za-z_]([A-Za-z0-9_])*$');
-}
+ return null;
+ }
+};
diff --git a/wp-includes/js/wp-ajax-js.php b/wp-includes/js/wp-ajax-js.php
index e56cba9..0d4cf2b 100644
--- a/wp-includes/js/wp-ajax-js.php
+++ b/wp-includes/js/wp-ajax-js.php
@@ -19,7 +19,7 @@ Object.extend(WPAjax.prototype, {
tempObj.WPError(transport);
}
});
- this.url = url;
+ this.url = url ? url : '<?php bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php';
this.getResponseElement(responseEl);
},
addArg: function(key, value) {
@@ -91,3 +91,6 @@ Ajax.Responders.register( {
window.onbeforeunload = wpBeforeUnload;
}
});
+
+//Pretty func adapted from ALA http://www.alistapart.com/articles/gettingstartedwithajax
+function getNodeValue(tree,el){try { var r = tree.getElementsByTagName(el)[0].firstChild.nodeValue; } catch(err) { var r = null; } return r; }
diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php
index b2b099c..b536b92 100644
--- a/wp-includes/l10n.php
+++ b/wp-includes/l10n.php
@@ -17,7 +17,7 @@ function get_locale() {
return $locale;
}
-// Return a translated string.
+// Return a translated string.
function __($text, $domain = 'default') {
global $l10n;
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index c4002bd..151a986 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -63,7 +63,7 @@ function get_permalink($id = 0) {
$authordata = get_userdata($post->post_author);
$author = $authordata->user_nicename;
$date = explode(" ",date('Y m d H i s', $unixtime));
- $rewritereplace =
+ $rewritereplace =
array(
$date[0],
$date[1],
@@ -89,7 +89,23 @@ function post_permalink($post_id = 0, $mode = '') { // $mode legacy
return get_permalink($post_id);
}
+// Respects page_on_front. Use this one.
function get_page_link($id = false) {
+ global $post;
+
+ if ( !$id )
+ $id = $post->ID;
+
+ if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
+ $link = get_option('home');
+ else
+ $link = _get_page_link( $id );
+
+ return apply_filters('page_link', $link, $id);
+}
+
+// Ignores page_on_front. Internal use only.
+function _get_page_link( $id = false ) {
global $post, $wp_rewrite;
if ( !$id )
@@ -105,10 +121,7 @@ function get_page_link($id = false) {
$link = get_option('home') . "/?page_id=$id";
}
- if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
- $link = get_option('home');
-
- return apply_filters('page_link', $link, $id);
+ return apply_filters( '_get_page_link', $link, $id );
}
function get_attachment_link($id = false) {
@@ -123,7 +136,10 @@ function get_attachment_link($id = false) {
$object = get_post($id);
if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) ) {
$parent = get_post($object->post_parent);
- $parentlink = get_permalink($object->post_parent);
+ if ( 'page' == $parent->post_type )
+ $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front
+ else
+ $parentlink = get_permalink( $object->post_parent );
if (! strstr($parentlink, '?') )
$link = trim($parentlink, '/') . '/' . $object->post_name . '/';
}
@@ -266,7 +282,7 @@ function get_previous_post($in_same_cat = false, $excluded_categories = '') {
for ( $i = 1; $i < (count($cat_array)); $i++ ) {
$join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
}
- $join .= ')';
+ $join .= ')';
}
$sql_exclude_cats = '';
@@ -299,7 +315,7 @@ function get_next_post($in_same_cat = false, $excluded_categories = '') {
for ( $i = 1; $i < (count($cat_array)); $i++ ) {
$join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
}
- $join .= ')';
+ $join .= ')';
}
$sql_exclude_cats = '';
@@ -334,7 +350,7 @@ function previous_post_link($format='&laquo; %link', $link='%title', $in_same_ca
$format = str_replace('%link', $link, $format);
- echo $format;
+ echo $format;
}
function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
@@ -349,7 +365,7 @@ function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat =
$link = $string . $link . '</a>';
$format = str_replace('%link', $link, $format);
- echo $format;
+ echo $format;
}
function get_pagenum_link($pagenum = 1) {
@@ -357,7 +373,7 @@ function get_pagenum_link($pagenum = 1) {
$qstr = wp_specialchars($_SERVER['REQUEST_URI']);
- $page_querystring = "paged";
+ $page_querystring = "paged";
$page_modstring = "page/";
$page_modregex = "page/?";
$permalink = 0;
@@ -435,9 +451,9 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
}
function next_posts_link($label='Next Page &raquo;', $max_page=0) {
- global $paged, $wpdb;
+ global $paged, $wpdb, $wp_query;
if ( !$max_page ) {
- $max_page = _max_num_pages();
+ $max_page = $wp_query->max_num_pages;
}
if ( !$paged )
$paged = 1;
@@ -471,34 +487,12 @@ function previous_posts_link($label='&laquo; Previous Page') {
}
}
-function _max_num_pages() {
- static $max_num_pages;
- global $wpdb, $wp_query;
-
- if (isset($max_num_pages)) return $max_num_pages;
- $posts_per = get_query_var('posts_per_page');
- if ( empty($posts_per) ) $posts_per = 1;
-
- if ( 'posts' == get_query_var('what_to_show') ) {
- preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
- $fromwhere = $matches[1];
- $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT $wpdb->posts.ID) FROM $fromwhere");
- $max_num_pages = ceil($numposts / $posts_per);
- } else {
- preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
- $fromwhere = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
- $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
- $max_num_pages = ceil($num_days / $posts_per);
- }
-
- return $max_num_pages;
-}
-
function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
- if ( !is_single() ) {
- $max_num_pages = _max_num_pages();
+ global $wp_query;
+ if ( !is_singular() ) {
+ $max_num_pages = $wp_query->max_num_pages;
$paged = get_query_var('paged');
-
+
//only have sep if there's both prev and next results
if ($paged < 2 || $paged >= $max_num_pages) {
$sep = '';
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 18426d6..a4bb24b 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -46,7 +46,7 @@ function get_currentuserinfo() {
if ( ! empty($current_user) )
return;
- if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
+ if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
wp_set_current_user(0);
return false;
@@ -218,7 +218,7 @@ endif;
if ( !function_exists('auth_redirect') ) :
function auth_redirect() {
// Checks if a user is logged in, if not redirects them to the login page
- if ( (!empty($_COOKIE[USER_COOKIE]) &&
+ if ( (!empty($_COOKIE[USER_COOKIE]) &&
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
(empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers();
@@ -278,7 +278,8 @@ function wp_redirect($location, $status = 302) {
if ( $is_IIS ) {
header("Refresh: 0;url=$location");
} else {
- status_header($status); // This causes problems on IIS
+ if ( php_sapi_name() != 'cgi-fcgi' )
+ status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location");
}
}
@@ -339,7 +340,7 @@ endif;
if ( ! function_exists('wp_notify_postauthor') ) :
function wp_notify_postauthor($comment_id, $comment_type='') {
global $wpdb;
-
+
$comment = get_comment($comment_id);
$post = get_post($comment->comment_post_ID);
$user = get_userdata( $post->post_author );
@@ -386,11 +387,11 @@ function wp_notify_postauthor($comment_id, $comment_type='') {
$from = "From: \"$blogname\" <$admin_email>";
if ( '' != $comment->comment_author_email )
$reply_to = "Reply-To: $comment->comment_author_email";
- } else {
+ } else {
$from = "From: \"$comment->comment_author\" <$admin_email>";
if ( '' != $comment->comment_author_email )
$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
- }
+ }
$message_headers = "MIME-Version: 1.0\n"
. "$from\n"
@@ -434,9 +435,9 @@ function wp_notify_moderator($comment_id) {
$notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n";
$notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
- $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=mac&c=$comment_id" ) . "\r\n";
- $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n";
- $notify_message .= sprintf( __('To mark this comment as spam, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Approve it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=mac&c=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Delete it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Spam it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n";
$notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n";
$notify_message .= get_option('siteurl') . "/wp-admin/moderation.php\r\n";
@@ -447,7 +448,7 @@ function wp_notify_moderator($comment_id) {
$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
@wp_mail($admin_email, $subject, $notify_message);
-
+
return true;
}
endif;
@@ -497,7 +498,7 @@ function wp_create_nonce($action = -1) {
$uid = $user->id;
$i = ceil(time() / 43200);
-
+
return substr(wp_hash($i . $action . $uid), -12, 10);
}
endif;
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 40606ae..642f664 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -8,25 +8,27 @@ function get_attached_file($attachment_id) {
return get_post_meta($attachment_id, '_wp_attached_file', true);
}
-function &get_children($post = 0, $output = OBJECT) {
+function &get_children($args = '', $output = OBJECT) {
global $post_cache, $wpdb, $blog_id;
- if ( empty($post) ) {
+ if ( empty($args) ) {
if ( isset($GLOBALS['post']) )
- $post_parent = & $GLOBALS['post']->post_parent;
+ $r = array('post_parent' => & $GLOBALS['post']->post_parent);
else
return false;
- } elseif ( is_object($post) ) {
- $post_parent = $post->post_parent;
- } else {
- $post_parent = $post;
- }
-
- $post_parent = (int) $post_parent;
+ } 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);
- $query = "SELECT * FROM $wpdb->posts WHERE post_parent = $post_parent";
+ $defaults = array('numberposts' => -1, 'post_type' => '', 'post_status' => '', 'post_parent' => 0);
+ $r = array_merge($defaults, $r);
- $children = $wpdb->get_results($query);
+ $children = get_posts( $r );
if ( $children ) {
foreach ( $children as $key => $child ) {
@@ -158,18 +160,24 @@ function get_posts($args) {
else
parse_str($args, $r);
- $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => '',
- 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' =>'');
+ $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);
+ $numberposts = (int) $numberposts;
+ $offset = (int) $offset;
+ $category = (int) $category;
+ $post_parent = (int) $post_parent;
$inclusions = '';
if ( !empty($include) ) {
- $offset = 0; //ignore offset, category, exclude, meta_key, and meta_value params if using include
- $category = '';
- $exclude = '';
+ $offset = 0; //ignore offset, category, exclude, meta_key, and meta_value, post_parent if using include
+ $category = 0;
+ $exclude = '';
$meta_key = '';
$meta_value = '';
+ $post_parent = 0;
$incposts = preg_split('/[\s,]+/',$include);
$numberposts = count($incposts); // only the number of posts included
if ( count($incposts) ) {
@@ -181,8 +189,8 @@ function get_posts($args) {
}
}
}
- if (!empty($inclusions))
- $inclusions .= ')';
+ if (!empty($inclusions))
+ $inclusions .= ')';
$exclusions = '';
if ( !empty($exclude) ) {
@@ -196,16 +204,30 @@ function get_posts($args) {
}
}
}
- if (!empty($exclusions))
+ if (!empty($exclusions))
$exclusions .= ')';
$query ="SELECT DISTINCT * FROM $wpdb->posts " ;
- $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " ) ;
- $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ;
- $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions " ;
- $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " ) ;
- $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ;
- $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts ;
+ $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " );
+ $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " );
+ $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions ";
+ $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " );
+ $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" );
+ $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts;
+
+ $query = "SELECT DISTINCT * FROM $wpdb->posts ";
+ $query .= empty( $category ) ? '' : ", $wpdb->post2cat ";
+ $query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta ";
+ $query .= " WHERE 1=1 ";
+ $query .= empty( $post_type ) ? '' : "AND post_type = '$post_type' ";
+ $query .= empty( $post_status ) ? '' : "AND post_status = '$post_status' ";
+ $query .= "$exclusions $inclusions " ;
+ $query .= empty( $category ) ? '' : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") ";
+ $query .= empty( $post_parent ) ? '' : "AND $wpdb->posts.post_parent = '$post_parent' ";
+ $query .= empty( $meta_key ) | empty($meta_value) ? '' : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )";
+ $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . ' ' . $order;
+ if ( 0 < $numberposts )
+ $query .= " LIMIT " . $offset . ',' . $numberposts;
$posts = $wpdb->get_results($query);
@@ -229,7 +251,7 @@ function add_post_meta($post_id, $key, $value, $unique = false) {
}
}
- $post_meta_cache[$blog_id][$post_id][$key][] = $original;
+ $post_meta_cache[$blog_id][$post_id][$key][] = $value;
$value = maybe_serialize($value);
$value = $wpdb->escape($value);
@@ -274,6 +296,14 @@ function get_post_meta($post_id, $key, $single = false) {
$post_id = (int) $post_id;
+ if ( isset($post_meta_cache[$blog_id][$post_id][$key]) ) {
+ if ( $single ) {
+ return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key][0] );
+ } else {
+ return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key] );
+ }
+ }
+
if ( !isset($post_meta_cache[$blog_id][$post_id]) )
update_postmeta_cache($post_id);
@@ -392,6 +422,8 @@ function wp_delete_post($postid = 0) {
$wp_rewrite->flush_rules();
}
+ do_action('post_deleted', $postid);
+
return $post;
}
@@ -400,9 +432,9 @@ function wp_get_post_categories($post_ID = 0) {
$post_ID = (int) $post_ID;
- $sql = "SELECT category_id
- FROM $wpdb->post2cat
- WHERE post_id = '$post_ID'
+ $sql = "SELECT category_id
+ FROM $wpdb->post2cat
+ WHERE post_id = '$post_ID'
ORDER BY category_id";
$result = $wpdb->get_col($sql);
@@ -435,7 +467,7 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) {
// Set categories
if($mode == OBJECT) {
$post->post_category = wp_get_post_categories($postid);
- }
+ }
else {
$post['post_category'] = wp_get_post_categories($postid);
}
@@ -635,13 +667,13 @@ function wp_insert_post($postarr = array()) {
if ( !defined('WP_IMPORTING') ) {
if ( $post_pingback )
$result = $wpdb->query("
- INSERT INTO $wpdb->postmeta
- (post_id,meta_key,meta_value)
+ INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value)
VALUES ('$post_ID','_pingme','1')
");
$result = $wpdb->query("
- INSERT INTO $wpdb->postmeta
- (post_id,meta_key,meta_value)
+ INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value)
VALUES ('$post_ID','_encloseme','1')
");
wp_schedule_single_event(time(), 'do_pings');
@@ -653,7 +685,7 @@ function wp_insert_post($postarr = array()) {
if ( !empty($page_template) )
if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template))
add_post_meta($post_ID, '_wp_page_template', $page_template, true);
-
+
if ( $post_status == 'publish' )
do_action('publish_page', $post_ID);
}
@@ -684,22 +716,22 @@ function wp_update_post($postarr = array()) {
$post = add_magic_quotes($post);
// Passed post category list overwrites existing category list if not empty.
- if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
+ if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
&& 0 != count($postarr['post_category']) )
- $post_cats = $postarr['post_category'];
- else
- $post_cats = $post['post_category'];
+ $post_cats = $postarr['post_category'];
+ else
+ $post_cats = $post['post_category'];
// Drafts shouldn't be assigned a date unless explicitly done so by the user
- if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
- ('0000-00-00 00:00:00' == $post['post_date']) )
+ if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
+ ('0000-00-00 00:00:00' == $post['post_date']) )
$clear_date = true;
else
$clear_date = false;
- // Merge old and new fields with new fields overwriting old ones.
- $postarr = array_merge($post, $postarr);
- $postarr['post_category'] = $post_cats;
+ // Merge old and new fields with new fields overwriting old ones.
+ $postarr = array_merge($post, $postarr);
+ $postarr['post_category'] = $post_cats;
if ( $clear_date ) {
$postarr['post_date'] = '';
$postarr['post_date_gmt'] = '';
@@ -733,8 +765,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
// First the old categories
$old_categories = $wpdb->get_col("
- SELECT category_id
- FROM $wpdb->post2cat
+ SELECT category_id
+ FROM $wpdb->post2cat
WHERE post_id = $post_ID");
if (!$old_categories) {
@@ -749,9 +781,9 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
if ($delete_cats) {
foreach ($delete_cats as $del) {
$wpdb->query("
- DELETE FROM $wpdb->post2cat
- WHERE category_id = $del
- AND post_id = $post_ID
+ DELETE FROM $wpdb->post2cat
+ WHERE category_id = $del
+ AND post_id = $post_ID
");
}
}
@@ -774,7 +806,10 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
wp_cache_delete($cat_id, 'category');
+ do_action('edit_category', $cat_id);
}
+
+ do_action('edit_post', $post_ID);
} // wp_set_post_categories()
//
@@ -848,10 +883,10 @@ function trackback_url_list($tb_list, $post_id) {
$trackback_urls = explode(',', $tb_list);
foreach($trackback_urls as $tb_url) {
- $tb_url = trim($tb_url);
- trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
+ $tb_url = trim($tb_url);
+ trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
+ }
}
- }
}
//
@@ -891,7 +926,7 @@ function &get_page(&$page, $output = OBJECT) {
if ( isset($GLOBALS['page']->ID) && ($page == $GLOBALS['page']->ID) ) {
$_page = & $GLOBALS['page'];
wp_cache_add($_page->ID, $_page, 'pages');
- } elseif ( isset($_page) && $_page == $GLOBALS['post_cache'][$blog_id][$page] ) {
+ } elseif ( !isset($_page) && $_page == $GLOBALS['post_cache'][$blog_id][$page] ) {
return get_post($page, $output);
} elseif ( isset($_page) && $_page == wp_cache_get($page, 'pages') ) {
// Got it.
@@ -928,7 +963,7 @@ function get_page_by_path($page_path, $output = OBJECT) {
$pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'");
- if ( empty($pages) )
+ if ( empty($pages) )
return NULL;
foreach ($pages as $page) {
@@ -1016,6 +1051,11 @@ function &get_pages($args = '') {
$r = array_merge($defaults, $r);
extract($r);
+ $key = md5( serialize( $r ) );
+ if ( $cache = wp_cache_get( 'get_pages', 'page' ) )
+ if ( isset( $cache[ $key ] ) )
+ return apply_filters('get_pages', $cache[ $key ], $r );
+
$inclusions = '';
if ( !empty($include) ) {
$child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include
@@ -1095,9 +1135,17 @@ function &get_pages($args = '') {
if ( $child_of || $hierarchical )
$pages = & get_page_children($child_of, $pages);
+ $cache[ $key ] = $pages;
+ wp_cache_set( 'get_pages', $cache, 'page' );
+
return $pages;
}
+function delete_get_pages_cache() {
+ wp_cache_delete( 'get_pages', 'page' );
+}
+add_action( 'save_post', 'delete_get_pages_cache' );
+
function generate_page_uri_index() {
global $wpdb;
@@ -1196,7 +1244,7 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
if (empty($post_date))
$post_date = current_time('mysql');
- if (empty($post_date_gmt))
+ if (empty($post_date_gmt))
$post_date_gmt = current_time('mysql', 1);
if ( empty($comment_status) ) {
diff --git a/wp-includes/query.php b/wp-includes/query.php
index b2dd69d..6f5fbf0 100644
--- a/wp-includes/query.php
+++ b/wp-includes/query.php
@@ -3,7 +3,7 @@
/*
* The Big Query.
*/
-
+
function get_query_var($var) {
global $wp_query;
@@ -11,8 +11,9 @@ function get_query_var($var) {
}
function &query_posts($query) {
- global $wp_query;
- return $wp_query->query($query);
+ unset($GLOBALS['wp_query']);
+ $GLOBALS['wp_query'] =& new WP_Query();
+ return $GLOBALS['wp_query']->query($query);
}
/*
@@ -223,7 +224,7 @@ function is_404 () {
/*
* The Loop. Post loop control.
*/
-
+
function have_posts() {
global $wp_query;
@@ -265,6 +266,9 @@ class WP_Query {
var $in_the_loop = false;
var $post;
+ var $found_posts = 0;
+ var $max_num_pages = 0;
+
var $is_single = false;
var $is_preview = false;
var $is_page = false;
@@ -412,8 +416,8 @@ class WP_Query {
} elseif ( $qv['p'] ) {
$this->is_single = true;
} elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
- // If year, month, day, hour, minute, and second are set, a single
- // post is being queried.
+ // If year, month, day, hour, minute, and second are set, a single
+ // post is being queried.
$this->is_single = true;
} elseif ('' != $qv['static'] || '' != $qv['pagename'] || (int) $qv['page_id']) {
$this->is_page = true;
@@ -489,7 +493,7 @@ class WP_Query {
if ('' != $qv['category_name']) {
$this->is_category = true;
}
-
+
if ((empty($qv['author'])) || ($qv['author'] == '0')) {
$this->is_author = false;
} else {
@@ -583,14 +587,13 @@ class WP_Query {
$limits = '';
$join = '';
$search = '';
+ $groupby = '';
if ( !isset($q['post_type']) )
$q['post_type'] = 'post';
$post_type = $q['post_type'];
if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
$q['posts_per_page'] = get_option('posts_per_page');
- if ( !isset($q['what_to_show']) )
- $q['what_to_show'] = get_option('what_to_show');
if ( isset($q['showposts']) && $q['showposts'] ) {
$q['showposts'] = (int) $q['showposts'];
$q['posts_per_page'] = $q['showposts'];
@@ -606,7 +609,6 @@ class WP_Query {
}
if ( $this->is_feed ) {
$q['posts_per_page'] = get_option('posts_per_rss');
- $q['what_to_show'] = 'posts';
}
$q['posts_per_page'] = (int) $q['posts_per_page'];
if ( $q['posts_per_page'] < -1 )
@@ -693,6 +695,7 @@ class WP_Query {
$reqpage = 0;
if ( ('page' == get_option('show_on_front') ) && ( $reqpage == get_option('page_for_posts') ) ) {
+ $this->is_singular = false;
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
@@ -732,6 +735,7 @@ class WP_Query {
if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
$q['page_id'] = intval($q['page_id']);
if ( ('page' == get_option('show_on_front') ) && ( $q['page_id'] == get_option('page_for_posts') ) ) {
+ $this->is_singular = false;
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
@@ -767,7 +771,7 @@ class WP_Query {
// Category stuff
- if ((empty($q['cat'])) || ($q['cat'] == '0') ||
+ if ((empty($q['cat'])) || ($q['cat'] == '0') ||
// Bypass cat checks if fetching specific posts
( $this->is_single || $this->is_page )) {
$whichcat='';
@@ -784,7 +788,7 @@ class WP_Query {
if ( $in )
$in_cats .= "$cat, " . get_category_children($cat, '', ', ');
else
- $out_cats .= "$cat, " . get_category_children($cat, '', ', ');
+ $out_cats .= "$cat, " . get_category_children($cat, '', ', ');
}
$in_cats = substr($in_cats, 0, -2);
$out_cats = substr($out_cats, 0, -2);
@@ -801,12 +805,10 @@ class WP_Query {
$out_cats = " AND ID NOT IN ($out_posts)";
}
$whichcat = $in_cats . $out_cats;
- $distinct = 'DISTINCT';
+ $groupby = "{$wpdb->posts}.ID";
}
// Category stuff for nice URLs
-
- global $cache_categories;
if ('' != $q['category_name']) {
$reqcat = get_category_by_path($q['category_name']);
$q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name'])));
@@ -829,14 +831,14 @@ class WP_Query {
$reqcat = 0;
$q['cat'] = $reqcat;
-
+
$tables = ", $wpdb->post2cat, $wpdb->categories";
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
$whichcat = " AND category_id IN ({$q['cat']}, ";
$whichcat .= get_category_children($q['cat'], '', ', ');
$whichcat = substr($whichcat, 0, -2);
$whichcat .= ")";
- $distinct = 'DISTINCT';
+ $groupby = "{$wpdb->posts}.ID";
}
// Author/user stuff
@@ -920,7 +922,7 @@ class WP_Query {
if ( is_admin() )
$where .= " OR post_status = 'future' OR post_status = 'draft'";
-
+
if ( is_user_logged_in() ) {
if ( 'post' == $post_type )
$cap = 'edit_private_posts';
@@ -942,40 +944,26 @@ class WP_Query {
$join = apply_filters('posts_join', $join);
// Paging
- if (empty($q['nopaging']) && ! $this->is_single && ! $this->is_page) {
+ if (empty($q['nopaging']) && !$this->is_singular) {
$page = abs(intval($q['paged']));
if (empty($page)) {
$page = 1;
}
- if (($q['what_to_show'] == 'posts')) {
- if ( empty($q['offset']) ) {
- $pgstrt = '';
- $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
- $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
- } else { // we're ignoring $page and using 'offset'
- $q['offset'] = abs(intval($q['offset']));
- $pgstrt = $q['offset'] . ', ';
- $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
- }
- } elseif ($q['what_to_show'] == 'days') {
- $startrow = $q['posts_per_page'] * (intval($page)-1);
- $start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");
- $endrow = $startrow + $q['posts_per_page'] - 1;
- $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
-
- if ($page > 1) {
- $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
- } else {
- $where .= " AND post_date >= '$end_date'";
- }
+ if ( empty($q['offset']) ) {
+ $pgstrt = '';
+ $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
+ $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
+ } else { // we're ignoring $page and using 'offset'
+ $q['offset'] = abs(intval($q['offset']));
+ $pgstrt = $q['offset'] . ', ';
+ $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
}
}
// Apply post-paging filters on where and join. Only plugins that
// manipulate paging queries should use these hooks.
$where = apply_filters('posts_where_paged', $where);
- $groupby = '';
$groupby = apply_filters('posts_groupby', $groupby);
if ( ! empty($groupby) )
$groupby = 'GROUP BY ' . $groupby;
@@ -983,11 +971,17 @@ class WP_Query {
$orderby = apply_filters('posts_orderby', $q['orderby']);
$distinct = apply_filters('posts_distinct', $distinct);
$fields = apply_filters('posts_fields', "$wpdb->posts.*");
- $request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
+ $found_rows = '';
+ if ( !empty($limits) )
+ $found_rows = 'SQL_CALC_FOUND_ROWS';
+ $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
$this->request = apply_filters('posts_request', $request);
$this->posts = $wpdb->get_results($this->request);
-
+ if ( !empty($limits) ) {
+ $this->found_posts = $wpdb->get_var('SELECT FOUND_ROWS()');
+ $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
+ }
// Check post status to determine if post should be displayed.
if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
$status = get_post_status($this->posts[0]);
@@ -1018,9 +1012,10 @@ class WP_Query {
}
}
+ $this->posts = apply_filters('the_posts', $this->posts);
+
update_post_caches($this->posts);
- $this->posts = apply_filters('the_posts', $this->posts);
$this->post_count = count($this->posts);
if ($this->post_count > 0) {
$this->post = $this->posts[0];
@@ -1030,7 +1025,7 @@ class WP_Query {
}
function next_post() {
-
+
$this->current_post++;
$this->post = $this->posts[$this->current_post];
@@ -1066,7 +1061,7 @@ class WP_Query {
$this->post = $this->posts[0];
}
}
-
+
function &query($query) {
$this->parse_query($query);
return $this->get_posts();
diff --git a/wp-includes/registration.php b/wp-includes/registration.php
index 8ec38a4..39b931c 100644
--- a/wp-includes/registration.php
+++ b/wp-includes/registration.php
@@ -85,9 +85,9 @@ function wp_insert_user($userdata) {
$wpdb->query( $query );
$user_id = $ID;
} else {
- $query = "INSERT INTO $wpdb->users
+ $query = "INSERT INTO $wpdb->users
(user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name)
- VALUES
+ VALUES
('$user_login', '$user_pass', '$user_email', '$user_url', '$user_registered', '$user_nicename', '$display_name')";
$query = apply_filters('create_user_query', $query);
$wpdb->query( $query );
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index 571f0c0..4b35e3b 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -16,15 +16,15 @@ function add_rewrite_tag($tagname, $regex) {
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/
+//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
@@ -169,7 +169,7 @@ class WP_Rewrite {
var $non_wp_rules; //rules that don't redirect to WP's index.php
var $endpoints;
var $use_verbose_rules = false;
- var $rewritecode =
+ var $rewritecode =
array(
'%year%',
'%monthnum%',
@@ -185,7 +185,7 @@ class WP_Rewrite {
'%search%'
);
- var $rewritereplace =
+ var $rewritereplace =
array(
'([0-9]{4})',
'([0-9]{1,2})',
@@ -201,7 +201,7 @@ class WP_Rewrite {
'(.+)'
);
- var $queryreplace =
+ var $queryreplace =
array (
'year=',
'monthnum=',
@@ -218,7 +218,7 @@ class WP_Rewrite {
);
var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
-
+
function using_permalinks() {
if (empty($this->permalink_structure))
return false;
@@ -235,7 +235,7 @@ class WP_Rewrite {
if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
return true;
}
-
+
return false;
}
@@ -251,11 +251,11 @@ class WP_Rewrite {
$match_suffix = '';
if (! empty($this->matches)) {
- $match_prefix = '$' . $this->matches . '[';
+ $match_prefix = '$' . $this->matches . '[';
$match_suffix = ']';
- }
+ }
- return "$match_prefix$number$match_suffix";
+ return "$match_prefix$number$match_suffix";
}
function page_rewrite_rules() {
@@ -301,13 +301,13 @@ class WP_Rewrite {
$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/.
+ // structure. If they do, move the date tags to $front/date/.
$front = $this->front;
preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
$tok_index = 1;
@@ -482,11 +482,11 @@ class WP_Rewrite {
//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) {
+ 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
@@ -511,7 +511,7 @@ class WP_Rewrite {
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;
}
@@ -548,7 +548,7 @@ class WP_Rewrite {
$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;
@@ -580,15 +580,15 @@ class WP_Rewrite {
$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
if ($paged) //...and /page/xx ones
$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
-
+
//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
+
+ //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
+ //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 (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
|| strstr($struct, '%pagename%')
@@ -597,7 +597,7 @@ class WP_Rewrite {
if ( strstr($struct, '%pagename%') )
$page = true;
}
-
+
//do endpoints
if ($endpoints) {
foreach ($ep_query_append as $regex => $ep) {
@@ -607,7 +607,7 @@ class WP_Rewrite {
}
}
}
-
+
//if we're creating rules for a permalink, do all the endpoints like attachments etc
if ($post) {
$post = true;
@@ -618,7 +618,7 @@ class WP_Rewrite {
$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/...
@@ -626,19 +626,19 @@ class WP_Rewrite {
$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) {
@@ -646,11 +646,11 @@ class WP_Rewrite {
$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);
@@ -659,7 +659,7 @@ class WP_Rewrite {
$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
@@ -669,7 +669,7 @@ class WP_Rewrite {
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));
@@ -763,11 +763,11 @@ class WP_Rewrite {
$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.
@@ -819,7 +819,7 @@ class WP_Rewrite {
return $rules;
}
-
+
//Add a straight rewrite rule
function add_rule($regex, $redirect) {
//get everything up to the first ?
@@ -831,12 +831,12 @@ class WP_Rewrite {
$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;
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index f5585ec..0c33252 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -15,18 +15,13 @@ class WP_Scripts {
$this->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' );
$this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3517' );
$this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
- $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '09212006a' );
+ $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20061113' );
$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'), '20061006' );
+ $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20061113' );
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0');
- $this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4211');
- $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4187');
- $this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4187');
- $this->add( 'scriptaculous', '/wp-includes/js/scriptaculous/scriptaculous.js', array('prototype'), '1.6.1');
- $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/scriptaculous.js?load=builder,dragdrop', array('prototype'), '1.6.1');
- $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/scriptaculous.js?load=controls', array('prototype'), '1.6.1');
- $this->add( 'cropper', '/wp-content/themes/connections/crop/cropper.js', array('scriptaculous-dragdrop'), '1');
- $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '1');
+ $this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4508');
+ $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4459');
+ $this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4459');
if ( is_admin() ) {
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
@@ -35,7 +30,7 @@ class WP_Scripts {
$this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' );
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
- $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '4355b' );
+ $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '4466b' );
}
}
@@ -80,7 +75,7 @@ class WP_Scripts {
}
}
}
-
+
/**
* Determines dependencies of scripts
@@ -169,7 +164,7 @@ class WP_Scripts {
endswitch;
return false;
}
-
+
}
class _WP_Script {
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index d8051da..46f7249 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -1,6 +1,6 @@
<?php
/*
- * Theme/template/stylesheet functions.
+ * Theme/template/stylesheet functions.
*/
function get_stylesheet() {
@@ -14,7 +14,7 @@ function get_stylesheet_directory() {
}
function get_stylesheet_directory_uri() {
- $stylesheet = rawurlencode( get_stylesheet() );
+ $stylesheet = get_stylesheet();
$stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
}
@@ -32,7 +32,7 @@ function get_locale_stylesheet_uri() {
$locale = get_locale();
if ( file_exists("$dir/$locale.css") )
$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
- else if ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
+ elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
else
$stylesheet_uri = '';
@@ -88,8 +88,7 @@ function get_theme_data($theme_file) {
}
function get_themes() {
- global $wp_themes;
- global $wp_broken_themes;
+ global $wp_themes, $wp_broken_themes;
if ( isset($wp_themes) )
return $wp_themes;
@@ -99,53 +98,70 @@ function get_themes() {
$theme_root = get_theme_root();
$theme_loc = str_replace(ABSPATH, '', $theme_root);
- // Files in wp-content/themes directory
+ // Files in wp-content/themes directory and one subdir down
$themes_dir = @ dir($theme_root);
- if ( $themes_dir ) {
- while(($theme_dir = $themes_dir->read()) !== false) {
- if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
- if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {
- continue;
+ if ( !$themes_dir )
+ return false;
+
+ while ( ($theme_dir = $themes_dir->read()) !== false ) {
+ if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
+ if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
+ continue;
+ $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
+ $found_stylesheet = false;
+ while ( ($theme_file = $stylish_dir->read()) !== false ) {
+ if ( $theme_file == 'style.css' ) {
+ $theme_files[] = $theme_dir . '/' . $theme_file;
+ $found_stylesheet = true;
+ break;
}
- $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
- $found_stylesheet = false;
- while (($theme_file = $stylish_dir->read()) !== false) {
- if ( $theme_file == 'style.css' ) {
- $theme_files[] = $theme_dir . '/' . $theme_file;
- $found_stylesheet = true;
- break;
+ }
+ if ( !$found_stylesheet ) { // look for themes in that dir
+ $subdir = "$theme_root/$theme_dir";
+ $subdir_name = $theme_dir;
+ $theme_subdir = @dir( $subdir );
+ while ( ($theme_dir = $theme_subdir->read()) !== false ) {
+ if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) {
+ if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
+ continue;
+ $stylish_dir = @ dir($subdir . '/' . $theme_dir);
+ $found_stylesheet = false;
+ while ( ($theme_file = $stylish_dir->read()) !== false ) {
+ if ( $theme_file == 'style.css' ) {
+ $theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file;
+ $found_stylesheet = true;
+ break;
+ }
+ }
}
}
- if ( !$found_stylesheet ) {
- $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
- }
+ $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
}
}
}
- if ( !$themes_dir || !$theme_files ) {
+ if ( !$themes_dir || !$theme_files )
return $themes;
- }
sort($theme_files);
- foreach($theme_files as $theme_file) {
- if ( ! is_readable("$theme_root/$theme_file") ) {
+ foreach ( (array) $theme_files as $theme_file ) {
+ if ( !is_readable("$theme_root/$theme_file") ) {
$wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
continue;
}
$theme_data = get_theme_data("$theme_root/$theme_file");
- $name = $theme_data['Name'];
- $title = $theme_data['Title'];
+ $name = $theme_data['Name'];
+ $title = $theme_data['Title'];
$description = wptexturize($theme_data['Description']);
- $version = $theme_data['Version'];
- $author = $theme_data['Author'];
- $template = $theme_data['Template'];
- $stylesheet = dirname($theme_file);
+ $version = $theme_data['Version'];
+ $author = $theme_data['Author'];
+ $template = $theme_data['Template'];
+ $stylesheet = dirname($theme_file);
- foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
+ foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
$screenshot = "screenshot.$ext";
break;
@@ -158,24 +174,28 @@ function get_themes() {
}
if ( empty($template) ) {
- if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) {
+ if ( file_exists(dirname("$theme_root/$theme_file/index.php")) )
$template = dirname($theme_file);
- } else {
+ else
continue;
- }
}
$template = trim($template);
if ( !file_exists("$theme_root/$template/index.php") ) {
- $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
- continue;
+ $parent_dir = dirname(dirname($theme_file));
+ if ( file_exists("$theme_root/$parent_dir/$template/index.php") ) {
+ $template = "$parent_dir/$template";
+ } else {
+ $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
+ continue;
+ }
}
$stylesheet_files = array();
$stylesheet_dir = @ dir("$theme_root/$stylesheet");
if ( $stylesheet_dir ) {
- while(($file = $stylesheet_dir->read()) !== false) {
+ while ( ($file = $stylesheet_dir->read()) !== false ) {
if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
$stylesheet_files[] = "$theme_loc/$stylesheet/$file";
}
@@ -222,10 +242,10 @@ function get_themes() {
// Resolve theme dependencies.
$theme_names = array_keys($themes);
- foreach ($theme_names as $theme_name) {
+ foreach ( (array) $theme_names as $theme_name ) {
$themes[$theme_name]['Parent Theme'] = '';
if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
- foreach ($theme_names as $parent_theme_name) {
+ foreach ( (array) $theme_names as $parent_theme_name ) {
if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
$themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
break;
@@ -256,7 +276,7 @@ function get_current_theme() {
$current_theme = 'WordPress Default';
if ( $themes ) {
- foreach ($theme_names as $theme_name) {
+ foreach ( (array) $theme_names as $theme_name ) {
if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
$themes[$theme_name]['Template'] == $current_template ) {
$current_theme = $themes[$theme_name]['Name'];
@@ -300,7 +320,7 @@ function get_category_template() {
$template = '';
if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
$template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
- else if ( file_exists(TEMPLATEPATH . "/category.php") )
+ elseif ( file_exists(TEMPLATEPATH . "/category.php") )
$template = TEMPLATEPATH . "/category.php";
return apply_filters('category_template', $template);
@@ -315,7 +335,7 @@ function get_home_template() {
if ( file_exists(TEMPLATEPATH . "/home.php") )
$template = TEMPLATEPATH . "/home.php";
- else if ( file_exists(TEMPLATEPATH . "/index.php") )
+ elseif ( file_exists(TEMPLATEPATH . "/index.php") )
$template = TEMPLATEPATH . "/index.php";
return apply_filters('home_template', $template);
@@ -330,9 +350,9 @@ function get_page_template() {
if ( 'default' == $template )
$template = '';
- if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
+ if ( !empty($template) && file_exists(TEMPLATEPATH . "/$template") )
$template = TEMPLATEPATH . "/$template";
- else if ( file_exists(TEMPLATEPATH . "/page.php") )
+ elseif ( file_exists(TEMPLATEPATH . "/page.php") )
$template = TEMPLATEPATH . "/page.php";
else
$template = '';
@@ -374,14 +394,13 @@ function get_comments_popup_template() {
return apply_filters('comments_popup_template', $template);
}
-function load_template($file) {
+function load_template($_template_file) {
global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
$wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment;
- if( is_array( $wp_query->query_vars ) )
- extract($wp_query->query_vars);
+ extract($wp_query->query_vars, EXTR_SKIP);
- require_once($file);
+ require_once($_template_file);
}
function locale_stylesheet() {
@@ -396,14 +415,14 @@ function validate_current_theme() {
if ( defined('WP_INSTALLING') )
return true;
- if ((get_template() != 'default') && (!file_exists(get_template_directory() . '/index.php'))) {
+ if ( get_template() != 'default' && !file_exists(get_template_directory() . '/index.php') ) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
return false;
}
- if ((get_stylesheet() != 'default') && (!file_exists(get_template_directory() . '/style.css'))) {
+ if ( get_stylesheet() != 'default' && !file_exists(get_template_directory() . '/style.css') ) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
@@ -413,4 +432,32 @@ function validate_current_theme() {
return true;
}
+function get_theme_mod($name, $default = false) {
+ $theme = get_current_theme();
+
+ $mods = get_option("mods_$theme");
+
+ if ( isset($mods[$name]) )
+ return $mods[$name];
+
+ return sprintf($default, get_template_directory_uri());
+}
+
+function set_theme_mod($name, $value) {
+ $theme = get_current_theme();
+
+ $mods = get_option("mods_$theme");
+
+ $mods[$name] = $value;
+
+ update_option("mods_$theme", $mods);
+ wp_cache_delete("mods_$theme", 'options');
+}
+
+function remove_theme_mods() {
+ $theme = get_current_theme();
+
+ delete_option("mods_$theme");
+}
+
?>
diff --git a/wp-includes/user.php b/wp-includes/user.php
index d5828bb..e1f9770 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -152,7 +152,7 @@ function setup_userdata($user_id = '') {
if ( '' == $user_id )
$user = wp_get_current_user();
- else
+ else
$user = new WP_User($user_id);
if ( 0 == $user->ID )
diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php
index f543099..e1fe61e 100644
--- a/wp-includes/wp-db.php
+++ b/wp-includes/wp-db.php
@@ -97,7 +97,7 @@ class wpdb {
function print_error($str = '') {
global $EZSQL_ERROR;
if (!$str) $str = mysql_error();
- $EZSQL_ERROR[] =
+ $EZSQL_ERROR[] =
array ('query' => $this->last_query, 'error_str' => $str);
$str = htmlspecialchars($str, ENT_QUOTES);
diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php
index ec9746c..e4040c5 100644
--- a/wp-includes/wpmu-functions.php
+++ b/wp-includes/wpmu-functions.php
@@ -1387,4 +1387,19 @@ function get_current_site() {
return $current_site;
}
+function cat_is_ancestor_of($cat1, $cat2) {
+ if ( is_int($cat1) )
+ $cat1 = & get_category($cat1);
+ if ( is_int($cat2) )
+ $cat2 = & get_category($cat2);
+
+ if ( !$cat1->cat_ID || !$cat2->category_parent )
+ return false;
+
+ if ( $cat2->category_parent == $cat1->cat_ID )
+ return true;
+
+ return cat_is_ancestor_of($cat1, get_category($cat2->parent_category));
+}
+
?>
diff --git a/wp-links-opml.php b/wp-links-opml.php
index 7a2c220..9f15af4 100644
--- a/wp-links-opml.php
+++ b/wp-links-opml.php
@@ -16,11 +16,11 @@ if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
?><?php echo '<?xml version="1.0"?'.">\n"; ?>
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
<opml version="1.0">
- <head>
- <title>Links for <?php echo get_bloginfo('name').$cat_name ?></title>
- <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
- </head>
- <body>
+ <head>
+ <title>Links for <?php echo get_bloginfo('name').$cat_name ?></title>
+ <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
+ </head>
+ <body>
<?php
if (empty ($link_cat))
@@ -36,7 +36,7 @@ foreach ((array) $cats as $cat) {
$bookmarks = get_bookmarks("category={$cat->cat_ID}");
foreach ((array) $bookmarks as $bookmark) {
?>
- <outline text="<?php echo wp_specialchars($bookmark->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($bookmark->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />
+ <outline text="<?php echo wp_specialchars($bookmark->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($bookmark->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />
<?php
}
diff --git a/wp-login.php b/wp-login.php
index 50dbff2..d0deaae 100644
--- a/wp-login.php
+++ b/wp-login.php
@@ -200,7 +200,7 @@ break;
case 'auth' :
$_COOKIE = array(); // Prevent redirect loops caused by corrupted cookies
-case 'login' :
+case 'login' :
default:
$user_login = '';
$user_pass = '';
diff --git a/wp-rss.php b/wp-rss.php
index a342ee5..c10b065 100644
--- a/wp-rss.php
+++ b/wp-rss.php
@@ -21,7 +21,7 @@ $more = 1;
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('rss_head'); ?>
-<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+<?php while (have_posts()) : the_post(); ?>
<item>
<title><?php the_title_rss() ?></title>
<?php if (get_option('rss_use_excerpt')) { ?>
@@ -32,6 +32,6 @@ $more = 1;
<link><?php permalink_single_rss() ?></link>
<?php do_action('rss_item'); ?>
</item>
-<?php $items_count++; if (($items_count == get_option('posts_per_rss')) && empty($m)) { break; } } } ?>
+<?php endwhile; ?>
</channel>
</rss>
diff --git a/wp-rss2.php b/wp-rss2.php
index baec198..4addfc4 100644
--- a/wp-rss2.php
+++ b/wp-rss2.php
@@ -12,7 +12,7 @@ $more = 1;
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
-<rss version="2.0"
+<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/"
@@ -27,7 +27,7 @@ $more = 1;
<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('rss2_head'); ?>
- <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+ <?php while( have_posts()) : the_post(); ?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
@@ -51,6 +51,6 @@ $more = 1;
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
</item>
- <?php $items_count++; if (($items_count == get_option('posts_per_rss')) && !is_date()) { break; } } } ?>
+ <?php endwhile; ?>
</channel>
</rss>
diff --git a/wp-settings.php b/wp-settings.php
index 088d8fa..a777789 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -8,7 +8,7 @@ function wp_unregister_GLOBALS() {
return;
if ( isset($_REQUEST['GLOBALS']) )
- wp_die('GLOBALS overwrite attempt detected');
+ die('GLOBALS overwrite attempt detected');
// Variables that shouldn't be unset
$noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
@@ -57,7 +57,7 @@ if ( empty($PHP_SELF) )
if ( !(phpversion() >= '4.1') )
die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
-if ( !extension_loaded('mysql') )
+if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') )
die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
function timer_start() {
@@ -286,9 +286,10 @@ $_SERVER = add_magic_quotes($_SERVER);
do_action('sanitize_comment_cookies');
-$wp_query = new WP_Query();
-$wp_rewrite = new WP_Rewrite();
-$wp = new WP();
+$wp_the_query =& new WP_Query();
+$wp_query =& $wp_the_query;
+$wp_rewrite =& new WP_Rewrite();
+$wp =& new WP();
if( defined( "WP_INSTALLING" ) == false )
validate_current_theme();
@@ -301,7 +302,7 @@ load_default_textdomain();
// Pull in locale data after loading text domain.
require_once(ABSPATH . WPINC . '/locale.php');
-$wp_locale = new WP_Locale();
+$wp_locale =& new WP_Locale();
// Load functions for active theme.
if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
diff --git a/wp-trackback.php b/wp-trackback.php
index daa16c1..0d1813a 100644
--- a/wp-trackback.php
+++ b/wp-trackback.php
@@ -47,8 +47,8 @@ if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
$blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset);
}
-if ( is_single() || is_page() )
- $tb_id = $posts[0]->ID;
+if ( is_single() || is_page() )
+ $tb_id = $posts[0]->ID;
if ( !intval( $tb_id ) )
trackback_response(1, 'I really need an ID for this to work.');
diff --git a/xmlrpc.php b/xmlrpc.php
index 2437d27..94226dd 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -66,48 +66,48 @@ class wp_xmlrpc_server extends IXR_Server {
function wp_xmlrpc_server() {
$this->methods = array(
- // Blogger API
- 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
- 'blogger.getUserInfo' => 'this:blogger_getUserInfo',
- 'blogger.getPost' => 'this:blogger_getPost',
- 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
- 'blogger.getTemplate' => 'this:blogger_getTemplate',
- 'blogger.setTemplate' => 'this:blogger_setTemplate',
- 'blogger.newPost' => 'this:blogger_newPost',
- 'blogger.editPost' => 'this:blogger_editPost',
- 'blogger.deletePost' => 'this:blogger_deletePost',
-
- // MetaWeblog API (with MT extensions to structs)
- 'metaWeblog.newPost' => 'this:mw_newPost',
- 'metaWeblog.editPost' => 'this:mw_editPost',
- 'metaWeblog.getPost' => 'this:mw_getPost',
- 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
- 'metaWeblog.getCategories' => 'this:mw_getCategories',
- 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
-
- // MetaWeblog API aliases for Blogger API
- // see http://www.xmlrpc.com/stories/storyReader$2460
- 'metaWeblog.deletePost' => 'this:blogger_deletePost',
- 'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
- 'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
- 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
-
- // MovableType API
- 'mt.getCategoryList' => 'this:mt_getCategoryList',
- 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
- 'mt.getPostCategories' => 'this:mt_getPostCategories',
- 'mt.setPostCategories' => 'this:mt_setPostCategories',
- 'mt.supportedMethods' => 'this:mt_supportedMethods',
- 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
- 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
- 'mt.publishPost' => 'this:mt_publishPost',
-
- // PingBack
- 'pingback.ping' => 'this:pingback_ping',
- 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
-
- 'demo.sayHello' => 'this:sayHello',
- 'demo.addTwoNumbers' => 'this:addTwoNumbers'
+ // Blogger API
+ 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
+ 'blogger.getUserInfo' => 'this:blogger_getUserInfo',
+ 'blogger.getPost' => 'this:blogger_getPost',
+ 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
+ 'blogger.getTemplate' => 'this:blogger_getTemplate',
+ 'blogger.setTemplate' => 'this:blogger_setTemplate',
+ 'blogger.newPost' => 'this:blogger_newPost',
+ 'blogger.editPost' => 'this:blogger_editPost',
+ 'blogger.deletePost' => 'this:blogger_deletePost',
+
+ // MetaWeblog API (with MT extensions to structs)
+ 'metaWeblog.newPost' => 'this:mw_newPost',
+ 'metaWeblog.editPost' => 'this:mw_editPost',
+ 'metaWeblog.getPost' => 'this:mw_getPost',
+ 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
+ 'metaWeblog.getCategories' => 'this:mw_getCategories',
+ 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
+
+ // MetaWeblog API aliases for Blogger API
+ // see http://www.xmlrpc.com/stories/storyReader$2460
+ 'metaWeblog.deletePost' => 'this:blogger_deletePost',
+ 'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
+ 'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
+ 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
+
+ // MovableType API
+ 'mt.getCategoryList' => 'this:mt_getCategoryList',
+ 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
+ 'mt.getPostCategories' => 'this:mt_getPostCategories',
+ 'mt.setPostCategories' => 'this:mt_setPostCategories',
+ 'mt.supportedMethods' => 'this:mt_supportedMethods',
+ 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
+ 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
+ 'mt.publishPost' => 'this:mt_publishPost',
+
+ // PingBack
+ 'pingback.ping' => 'this:pingback_ping',
+ 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
+
+ 'demo.sayHello' => 'this:sayHello',
+ 'demo.addTwoNumbers' => 'this:addTwoNumbers'
);
$this->methods = apply_filters('xmlrpc_methods', $this->methods);
$this->IXR_Server($this->methods);
@@ -124,11 +124,11 @@ class wp_xmlrpc_server extends IXR_Server {
}
function login_pass_ok($user_login, $user_pass) {
- if (!user_pass_ok($user_login, $user_pass)) {
- $this->error = new IXR_Error(403, 'Bad login/pass combination.');
- return false;
- }
- return true;
+ if (!user_pass_ok($user_login, $user_pass)) {
+ $this->error = new IXR_Error(403, 'Bad login/pass combination.');
+ return false;
+ }
+ return true;
}
function escape(&$array) {
@@ -169,7 +169,7 @@ class wp_xmlrpc_server extends IXR_Server {
foreach ( $blogs as $blog ) {
$blog_id = $blog->userblog_id;
-
+
switch_to_blog($blog_id);
$is_admin = current_user_can('level_8');
@@ -191,25 +191,25 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
- $user_login = $args[1];
- $user_pass = $args[2];
+ $user_login = $args[1];
+ $user_pass = $args[2];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $user_data = get_userdatabylogin($user_login);
+ $user_data = get_userdatabylogin($user_login);
- $struct = array(
- 'nickname' => $user_data->nickname,
- 'userid' => $user_data->ID,
- 'url' => $user_data->user_url,
- 'email' => $user_data->user_email,
- 'lastname' => $user_data->last_name,
- 'firstname' => $user_data->first_name
- );
+ $struct = array(
+ 'nickname' => $user_data->nickname,
+ 'userid' => $user_data->ID,
+ 'url' => $user_data->user_url,
+ 'email' => $user_data->user_email,
+ 'lastname' => $user_data->last_name,
+ 'firstname' => $user_data->first_name
+ );
- return $struct;
+ return $struct;
}
@@ -218,81 +218,81 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
- $post_ID = $args[1];
- $user_login = $args[2];
- $user_pass = $args[3];
+ $post_ID = $args[1];
+ $user_login = $args[2];
+ $user_pass = $args[3];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $user_data = get_userdatabylogin($user_login);
- $post_data = wp_get_single_post($post_ID, ARRAY_A);
+ $user_data = get_userdatabylogin($user_login);
+ $post_data = wp_get_single_post($post_ID, ARRAY_A);
- $categories = implode(',', wp_get_post_categories($post_ID));
+ $categories = implode(',', wp_get_post_categories($post_ID));
- $content = '<title>'.stripslashes($post_data['post_title']).'</title>';
- $content .= '<category>'.$categories.'</category>';
- $content .= stripslashes($post_data['post_content']);
+ $content = '<title>'.stripslashes($post_data['post_title']).'</title>';
+ $content .= '<category>'.$categories.'</category>';
+ $content .= stripslashes($post_data['post_content']);
- $struct = array(
- 'userid' => $post_data['post_author'],
- 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])),
- 'content' => $content,
- 'postid' => $post_data['ID']
- );
+ $struct = array(
+ 'userid' => $post_data['post_author'],
+ 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'])),
+ 'content' => $content,
+ 'postid' => $post_data['ID']
+ );
- return $struct;
+ return $struct;
}
/* blogger.getRecentPosts ...gets recent posts */
function blogger_getRecentPosts($args) {
- global $wpdb;
+ global $wpdb;
$this->escape($args);
- $blog_ID = $args[1]; /* though we don't use it yet */
- $user_login = $args[2];
- $user_pass = $args[3];
- $num_posts = $args[4];
+ $blog_ID = $args[1]; /* though we don't use it yet */
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $num_posts = $args[4];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $posts_list = wp_get_recent_posts($num_posts);
+ $posts_list = wp_get_recent_posts($num_posts);
- if (!$posts_list) {
- $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
- return $this->error;
- }
+ if (!$posts_list) {
+ $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
+ return $this->error;
+ }
- foreach ($posts_list as $entry) {
-
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
- $categories = implode(',', wp_get_post_categories($entry['ID']));
+ foreach ($posts_list as $entry) {
- $content = '<title>'.stripslashes($entry['post_title']).'</title>';
- $content .= '<category>'.$categories.'</category>';
- $content .= stripslashes($entry['post_content']);
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+ $categories = implode(',', wp_get_post_categories($entry['ID']));
- $struct[] = array(
- 'userid' => $entry['post_author'],
- 'dateCreated' => new IXR_Date($post_date),
- 'content' => $content,
- 'postid' => $entry['ID'],
- );
+ $content = '<title>'.stripslashes($entry['post_title']).'</title>';
+ $content .= '<category>'.$categories.'</category>';
+ $content .= stripslashes($entry['post_content']);
- }
+ $struct[] = array(
+ 'userid' => $entry['post_author'],
+ 'dateCreated' => new IXR_Date($post_date),
+ 'content' => $content,
+ 'postid' => $entry['ID'],
+ );
- $recent_posts = array();
- for ($j=0; $j<count($struct); $j++) {
- array_push($recent_posts, $struct[$j]);
- }
+ }
+
+ $recent_posts = array();
+ for ($j=0; $j<count($struct); $j++) {
+ array_push($recent_posts, $struct[$j]);
+ }
- return $recent_posts;
+ return $recent_posts;
}
@@ -722,96 +722,96 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
- $blog_ID = $args[0];
- $user_login = $args[1];
- $user_pass = $args[2];
- $num_posts = $args[3];
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $num_posts = $args[3];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $posts_list = wp_get_recent_posts($num_posts);
+ $posts_list = wp_get_recent_posts($num_posts);
- if (!$posts_list) {
- $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
- return $this->error;
- }
+ if (!$posts_list) {
+ $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
+ return $this->error;
+ }
- foreach ($posts_list as $entry) {
-
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
- $categories = array();
- $catids = wp_get_post_categories($entry['ID']);
- foreach($catids as $catid) {
- $categories[] = get_cat_name($catid);
- }
+ foreach ($posts_list as $entry) {
- $post = get_extended($entry['post_content']);
- $link = post_permalink($entry['ID']);
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+ $categories = array();
+ $catids = wp_get_post_categories($entry['ID']);
+ foreach($catids as $catid) {
+ $categories[] = get_cat_name($catid);
+ }
- $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0;
- $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0;
+ $post = get_extended($entry['post_content']);
+ $link = post_permalink($entry['ID']);
- $struct[] = array(
- 'dateCreated' => new IXR_Date($post_date),
- 'userid' => $entry['post_author'],
- 'postid' => $entry['ID'],
- 'description' => $post['main'],
- 'title' => $entry['post_title'],
- 'link' => $link,
- 'permaLink' => $link,
+ $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0;
+ $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0;
+
+ $struct[] = array(
+ 'dateCreated' => new IXR_Date($post_date),
+ 'userid' => $entry['post_author'],
+ 'postid' => $entry['ID'],
+ 'description' => $post['main'],
+ 'title' => $entry['post_title'],
+ 'link' => $link,
+ 'permaLink' => $link,
// commented out because no other tool seems to use this
// 'content' => $entry['post_content'],
- 'categories' => $categories,
- 'mt_excerpt' => $entry['post_excerpt'],
- 'mt_text_more' => $post['extended'],
- 'mt_allow_comments' => $allow_comments,
- 'mt_allow_pings' => $allow_pings
- );
+ 'categories' => $categories,
+ 'mt_excerpt' => $entry['post_excerpt'],
+ 'mt_text_more' => $post['extended'],
+ 'mt_allow_comments' => $allow_comments,
+ 'mt_allow_pings' => $allow_pings
+ );
- }
+ }
- $recent_posts = array();
- for ($j=0; $j<count($struct); $j++) {
- array_push($recent_posts, $struct[$j]);
- }
-
- return $recent_posts;
+ $recent_posts = array();
+ for ($j=0; $j<count($struct); $j++) {
+ array_push($recent_posts, $struct[$j]);
+ }
+
+ return $recent_posts;
}
/* metaweblog.getCategories ...returns the list of categories on a given weblog */
function mw_getCategories($args) {
- global $wpdb;
+ global $wpdb;
$this->escape($args);
- $blog_ID = $args[0];
- $user_login = $args[1];
- $user_pass = $args[2];
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $categories_struct = array();
+ $categories_struct = array();
- // FIXME: can we avoid using direct SQL there?
- if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {
- foreach ($cats as $cat) {
- $struct['categoryId'] = $cat['cat_ID'];
- $struct['description'] = $cat['cat_name'];
- $struct['categoryName'] = $cat['cat_name'];
- $struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID']));
- $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name']));
+ // FIXME: can we avoid using direct SQL there?
+ if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {
+ foreach ($cats as $cat) {
+ $struct['categoryId'] = $cat['cat_ID'];
+ $struct['description'] = $cat['cat_name'];
+ $struct['categoryName'] = $cat['cat_name'];
+ $struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID']));
+ $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name']));
- $categories_struct[] = $struct;
- }
- }
+ $categories_struct[] = $struct;
+ }
+ }
- return $categories_struct;
+ return $categories_struct;
}
@@ -851,8 +851,7 @@ class wp_xmlrpc_server extends IXR_Server {
logIO('O', '(MW) Could not write file '.$name);
return new IXR_Error(500, 'Could not write file '.$name);
}
-
- return array('url' => $upload['url']);
+ return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ) );
}
@@ -865,72 +864,72 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
- $blog_ID = $args[0];
- $user_login = $args[1];
- $user_pass = $args[2];
- $num_posts = $args[3];
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $num_posts = $args[3];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $posts_list = wp_get_recent_posts($num_posts);
+ $posts_list = wp_get_recent_posts($num_posts);
- if (!$posts_list) {
- $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
- return $this->error;
- }
+ if (!$posts_list) {
+ $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
+ return $this->error;
+ }
- foreach ($posts_list as $entry) {
-
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
+ foreach ($posts_list as $entry) {
- $struct[] = array(
- 'dateCreated' => new IXR_Date($post_date),
- 'userid' => $entry['post_author'],
- 'postid' => $entry['ID'],
- 'title' => $entry['post_title'],
- );
+ $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
- }
+ $struct[] = array(
+ 'dateCreated' => new IXR_Date($post_date),
+ 'userid' => $entry['post_author'],
+ 'postid' => $entry['ID'],
+ 'title' => $entry['post_title'],
+ );
- $recent_posts = array();
- for ($j=0; $j<count($struct); $j++) {
- array_push($recent_posts, $struct[$j]);
- }
-
- return $recent_posts;
+ }
+
+ $recent_posts = array();
+ for ($j=0; $j<count($struct); $j++) {
+ array_push($recent_posts, $struct[$j]);
+ }
+
+ return $recent_posts;
}
/* mt.getCategoryList ...returns the list of categories on a given weblog */
function mt_getCategoryList($args) {
- global $wpdb;
+ global $wpdb;
$this->escape($args);
- $blog_ID = $args[0];
- $user_login = $args[1];
- $user_pass = $args[2];
+ $blog_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $categories_struct = array();
+ $categories_struct = array();
- // FIXME: can we avoid using direct SQL there?
- if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
- foreach ($cats as $cat) {
- $struct['categoryId'] = $cat['cat_ID'];
- $struct['categoryName'] = $cat['cat_name'];
+ // FIXME: can we avoid using direct SQL there?
+ if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
+ foreach ($cats as $cat) {
+ $struct['categoryId'] = $cat['cat_ID'];
+ $struct['categoryName'] = $cat['cat_name'];
- $categories_struct[] = $struct;
- }
- }
+ $categories_struct[] = $struct;
+ }
+ }
- return $categories_struct;
+ return $categories_struct;
}
@@ -939,28 +938,28 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
- $post_ID = $args[0];
- $user_login = $args[1];
- $user_pass = $args[2];
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- $categories = array();
- $catids = wp_get_post_categories(intval($post_ID));
- // first listed category will be the primary category
- $isPrimary = true;
- foreach($catids as $catid) {
- $categories[] = array(
- 'categoryName' => get_cat_name($catid),
- 'categoryId' => $catid,
- 'isPrimary' => $isPrimary
- );
- $isPrimary = false;
- }
-
- return $categories;
+ $categories = array();
+ $catids = wp_get_post_categories(intval($post_ID));
+ // first listed category will be the primary category
+ $isPrimary = true;
+ foreach($catids as $catid) {
+ $categories[] = array(
+ 'categoryName' => get_cat_name($catid),
+ 'categoryId' => $catid,
+ 'isPrimary' => $isPrimary
+ );
+ $isPrimary = false;
+ }
+
+ return $categories;
}
@@ -969,81 +968,81 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
- $post_ID = $args[0];
- $user_login = $args[1];
- $user_pass = $args[2];
- $categories = $args[3];
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
+ $categories = $args[3];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- set_current_user(0, $user_login);
- if ( !current_user_can('edit_post', $post_ID) )
- return new IXR_Error(401, 'Sorry, you can not edit this post.');
+ set_current_user(0, $user_login);
+ if ( !current_user_can('edit_post', $post_ID) )
+ return new IXR_Error(401, 'Sorry, you can not edit this post.');
- foreach($categories as $cat) {
- $catids[] = $cat['categoryId'];
- }
+ foreach($categories as $cat) {
+ $catids[] = $cat['categoryId'];
+ }
- wp_set_post_categories($post_ID, $catids);
+ wp_set_post_categories($post_ID, $catids);
- return true;
+ return true;
}
/* mt.supportedMethods ...returns an array of methods supported by this server */
function mt_supportedMethods($args) {
- $supported_methods = array();
- foreach($this->methods as $key=>$value) {
- $supported_methods[] = $key;
- }
+ $supported_methods = array();
+ foreach($this->methods as $key=>$value) {
+ $supported_methods[] = $key;
+ }
- return $supported_methods;
+ return $supported_methods;
}
/* mt.supportedTextFilters ...returns an empty array because we don't
- support per-post text filters yet */
+ support per-post text filters yet */
function mt_supportedTextFilters($args) {
- return array();
+ return array();
}
/* mt.getTrackbackPings ...returns trackbacks sent to a given post */
function mt_getTrackbackPings($args) {
- global $wpdb;
+ global $wpdb;
- $post_ID = intval($args);
+ $post_ID = intval($args);
- $actual_post = wp_get_single_post($post_ID, ARRAY_A);
+ $actual_post = wp_get_single_post($post_ID, ARRAY_A);
- if (!$actual_post) {
- return new IXR_Error(404, 'Sorry, no such post.');
- }
+ if (!$actual_post) {
+ return new IXR_Error(404, 'Sorry, no such post.');
+ }
- $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
+ $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
- if (!$comments) {
- return array();
- }
+ if (!$comments) {
+ return array();
+ }
- $trackback_pings = array();
- foreach($comments as $comment) {
- if ( 'trackback' == $comment->comment_type ) {
- $content = $comment->comment_content;
- $title = substr($content, 8, (strpos($content, '</strong>') - 8));
- $trackback_pings[] = array(
- 'pingTitle' => $title,
- 'pingURL' => $comment->comment_author_url,
- 'pingIP' => $comment->comment_author_IP
- );
+ $trackback_pings = array();
+ foreach($comments as $comment) {
+ if ( 'trackback' == $comment->comment_type ) {
+ $content = $comment->comment_content;
+ $title = substr($content, 8, (strpos($content, '</strong>') - 8));
+ $trackback_pings[] = array(
+ 'pingTitle' => $title,
+ 'pingURL' => $comment->comment_author_url,
+ 'pingIP' => $comment->comment_author_IP
+ );
+ }
}
- }
- return $trackback_pings;
+ return $trackback_pings;
}
@@ -1052,30 +1051,30 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
- $post_ID = $args[0];
- $user_login = $args[1];
- $user_pass = $args[2];
+ $post_ID = $args[0];
+ $user_login = $args[1];
+ $user_pass = $args[2];
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- set_current_user(0, $user_login);
- if ( !current_user_can('edit_post', $post_ID) )
- return new IXR_Error(401, 'Sorry, you can not edit this post.');
+ set_current_user(0, $user_login);
+ if ( !current_user_can('edit_post', $post_ID) )
+ return new IXR_Error(401, 'Sorry, you can not edit this post.');
- $postdata = wp_get_single_post($post_ID,ARRAY_A);
+ $postdata = wp_get_single_post($post_ID,ARRAY_A);
- $postdata['post_status'] = 'publish';
+ $postdata['post_status'] = 'publish';
- // retain old cats
- $cats = wp_get_post_categories($post_ID);
- $postdata['post_category'] = $cats;
+ // retain old cats
+ $cats = wp_get_post_categories($post_ID);
+ $postdata['post_category'] = $cats;
$this->escape($postdata);
- $result = wp_update_post($postdata);
+ $result = wp_update_post($postdata);
- return $result;
+ return $result;
}
@@ -1086,7 +1085,7 @@ class wp_xmlrpc_server extends IXR_Server {
/* pingback.ping gets a pingback and registers it */
function pingback_ping($args) {
- global $wpdb, $wp_version;
+ global $wpdb, $wp_version;
$this->escape($args);
@@ -1103,7 +1102,7 @@ class wp_xmlrpc_server extends IXR_Server {
// Check if the page linked to is in our site
$pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home')));
if( !$pos1 )
- return new IXR_Error(0, 'Is there no link to us?');
+ return new IXR_Error(0, 'Is there no link to us?');
// let's find which post is linked to
// FIXME: does url_to_postid() cover all these cases already?
@@ -1236,8 +1235,8 @@ class wp_xmlrpc_server extends IXR_Server {
/* pingback.extensions.getPingbacks returns an array of URLs
- that pingbacked the given URL
- specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */
+ that pingbacked the given URL
+ specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */
function pingback_extensions_getPingbacks($args) {
global $wpdb;