From 89fe0ff804e7c6497ebacc8b341ac89974f6f255 Mon Sep 17 00:00:00 2001 From: donncha Date: Mon, 21 May 2007 18:37:58 +0000 Subject: WP Merge to rev 5499, this is a big one! Test it before you put it live! Test only, not for production use yet git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@972 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- app.php | 1260 -------- wp-admin/admin-ajax.php | 25 + wp-admin/admin-db.php | 20 + wp-admin/admin-footer.php | 2 +- wp-admin/admin-functions.php | 93 +- wp-admin/admin-header.php | 4 +- wp-admin/cat.js | 2 +- wp-admin/categories.js | 2 +- wp-admin/categories.php | 1 + wp-admin/comment.php | 2 +- wp-admin/custom-header.php | 17 +- wp-admin/dbx-admin-key.js | 2 +- wp-admin/edit-comments.js | 42 +- wp-admin/edit-comments.php | 161 +- wp-admin/edit-form-advanced.php | 11 +- wp-admin/edit-form-comment.php | 2 +- wp-admin/edit-link-form.php | 6 +- wp-admin/edit-page-form.php | 11 +- wp-admin/edit-pages.php | 6 +- wp-admin/edit.php | 4 +- wp-admin/export.php | 39 +- wp-admin/images/heading-bg.gif | Bin 0 -> 37 bytes wp-admin/import.php | 7 +- wp-admin/import/blogger.php | 4 +- wp-admin/import/dotclear.php | 32 +- wp-admin/import/greymatter.php | 8 +- wp-admin/import/livejournal.php | 3 +- wp-admin/import/mt.php | 3 + wp-admin/import/rss.php | 1 + wp-admin/import/textpattern.php | 36 +- wp-admin/import/utw.php | 270 ++ wp-admin/import/wordpress.php | 242 +- wp-admin/import/wp-cat2tag.php | 226 ++ wp-admin/index-extra.php | 14 +- wp-admin/index.php | 12 +- wp-admin/link-import.php | 8 +- wp-admin/link-manager.php | 2 +- wp-admin/menu.php | 1 + wp-admin/moderation.php | 8 +- wp-admin/options-permalink.php | 5 +- wp-admin/page.php | 6 - wp-admin/plugins.php | 20 + wp-admin/post-new.php | 4 +- wp-admin/post.php | 6 - wp-admin/profile.php | 24 +- wp-admin/rtl.css | 9 +- wp-admin/themes.php | 2 +- wp-admin/upgrade-functions.php | 38 +- wp-admin/upload-functions.php | 1 + wp-admin/upload.css | 1 + wp-admin/upload.php | 4 +- wp-admin/user-edit.php | 6 +- wp-admin/widgets-rtl.css | 39 + wp-admin/widgets.css | 214 ++ wp-admin/widgets.php | 390 +++ wp-admin/wp-admin.css | 30 +- wp-app.php | 1260 ++++++++ wp-comments-post.php | 6 + wp-config-sample.php | 60 +- wp-content/index.php | 4 +- wp-content/themes/classic/functions.php | 10 + wp-content/themes/classic/index.php | 6 +- wp-content/themes/classic/sidebar.php | 15 +- wp-content/themes/classic/style.css | 20 +- wp-content/themes/default/archive.php | 17 +- wp-content/themes/default/comments.php | 4 +- wp-content/themes/default/footer.php | 2 +- wp-content/themes/default/functions.php | 103 +- wp-content/themes/default/sidebar.php | 14 +- wp-cron.php | 2 +- wp-includes/author-template.php | 30 +- wp-includes/bookmark-template.php | 87 +- wp-includes/bookmark.php | 24 +- wp-includes/cache.php | 5 +- wp-includes/category-template.php | 68 +- wp-includes/category.php | 80 +- wp-includes/class-phpmailer.php | 2996 ++++++++++---------- wp-includes/class-smtp.php | 2090 +++++++------- wp-includes/class-snoopy.php | 2 +- wp-includes/classes.php | 20 +- wp-includes/comment-template.php | 8 +- wp-includes/comment.php | 42 +- wp-includes/compat.php | 7 + wp-includes/cron.php | 2 +- wp-includes/default-filters.php | 7 +- wp-includes/deprecated.php | 5 +- wp-includes/feed-atom-comments.php | 6 +- wp-includes/feed-atom.php | 2 +- wp-includes/feed-rdf.php | 2 +- wp-includes/feed-rss.php | 2 +- wp-includes/feed-rss2.php | 2 +- wp-includes/feed.php | 8 +- wp-includes/formatting.php | 19 +- wp-includes/functions.php | 138 +- wp-includes/general-template.php | 40 +- wp-includes/gettext.php | 714 ++--- wp-includes/images/rss.png | Bin 0 -> 3341 bytes wp-includes/js/prototype.js | 1440 +++++++--- wp-includes/js/quicktags.js | 14 +- wp-includes/js/scriptaculous/builder.js | 17 +- wp-includes/js/scriptaculous/controls.js | 78 +- wp-includes/js/scriptaculous/dragdrop.js | 43 +- wp-includes/js/scriptaculous/effects.js | 126 +- wp-includes/js/scriptaculous/scriptaculous.js | 21 +- wp-includes/js/scriptaculous/slider.js | 7 +- wp-includes/js/scriptaculous/sound.js | 60 + wp-includes/js/scriptaculous/unittest.js | 8 +- .../js/tinymce/plugins/autosave/editor_plugin.js | 4 +- .../plugins/directionality/editor_plugin.js | 4 +- .../tinymce/plugins/inlinepopups/editor_plugin.js | 242 +- .../js/tinymce/plugins/paste/editor_plugin.js | 14 +- .../spellchecker/classes/TinyGoogleSpell.class.php | 30 +- .../js/tinymce/plugins/wordpress/editor_plugin.js | 2 +- .../js/tinymce/plugins/wordpress/langs/en.js | 4 + .../js/tinymce/themes/advanced/color_picker.htm | 67 +- .../js/tinymce/themes/advanced/css/colorpicker.css | 53 + .../js/tinymce/themes/advanced/css/editor_ui.css | 10 +- .../js/tinymce/themes/advanced/editor_template.js | 76 +- .../js/tinymce/themes/advanced/images/colors.jpg | Bin 0 -> 3189 bytes .../themes/advanced/jscripts/color_picker.js | 221 +- .../js/tinymce/themes/advanced/jscripts/link.js | 5 +- wp-includes/js/tinymce/themes/advanced/langs/en.js | 11 +- wp-includes/js/tinymce/tiny_mce.js | 146 +- wp-includes/js/tinymce/tiny_mce_config.php | 7 +- wp-includes/js/tinymce/tiny_mce_gzip.php | 2 +- wp-includes/js/wp-ajax.js | 4 +- wp-includes/kses.php | 440 ++- wp-includes/l10n.php | 36 +- wp-includes/link-template.php | 177 +- wp-includes/locale.php | 12 + wp-includes/pluggable.php | 2 + wp-includes/plugin.php | 180 +- wp-includes/post-template.php | 73 +- wp-includes/post.php | 141 +- wp-includes/query.php | 6 +- wp-includes/rewrite.php | 31 +- wp-includes/rss.php | 5 +- wp-includes/script-loader.php | 61 +- wp-includes/theme.php | 46 +- wp-includes/user.php | 2 +- wp-includes/vars.php | 46 + wp-includes/version.php | 2 +- wp-links-opml.php | 2 +- wp-mail.php | 19 +- wp-settings.php | 10 +- xmlrpc.php | 93 +- 146 files changed, 9385 insertions(+), 6032 deletions(-) delete mode 100644 app.php create mode 100644 wp-admin/images/heading-bg.gif create mode 100644 wp-admin/import/utw.php create mode 100644 wp-admin/import/wp-cat2tag.php create mode 100644 wp-admin/widgets-rtl.css create mode 100644 wp-admin/widgets.css create mode 100644 wp-admin/widgets.php create mode 100644 wp-app.php create mode 100644 wp-content/themes/classic/functions.php create mode 100644 wp-includes/images/rss.png create mode 100644 wp-includes/js/scriptaculous/sound.js create mode 100644 wp-includes/js/tinymce/themes/advanced/css/colorpicker.css create mode 100644 wp-includes/js/tinymce/themes/advanced/images/colors.jpg diff --git a/app.php b/app.php deleted file mode 100644 index d64ccc2..0000000 --- a/app.php +++ /dev/null @@ -1,1260 +0,0 @@ -ID) ) - return $current_user; - - $current_user = new WP_User($id, $name); - - return $current_user; -} -endif; - -function wa_posts_where_include_drafts_filter($where) { - $where = ereg_replace("post_author = ([0-9]+) AND post_status != 'draft'","post_author = \\1 AND post_status = 'draft'", $where); - return $where; -} -add_filter('posts_where', 'wa_posts_where_include_drafts_filter'); - -class AtomEntry { - var $links = array(); - var $categories = array(); -} - -class AtomParser { - - var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights'); - var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft'); - - var $depth = 0; - var $indent = 2; - var $in_content; - var $ns_contexts = array(); - var $ns_decls = array(); - var $is_xhtml = false; - var $skipped_div = false; - - var $entry; - - function AtomParser() { - - $this->entry = new AtomEntry(); - $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";'); - $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";'); - } - - function parse() { - - global $app_logging; - array_unshift($this->ns_contexts, array()); - - $parser = xml_parser_create_ns(); - xml_set_object($parser, $this); - xml_set_element_handler($parser, "start_element", "end_element"); - xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); - xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); - xml_set_character_data_handler($parser, "cdata"); - xml_set_default_handler($parser, "_default"); - xml_set_start_namespace_decl_handler($parser, "start_ns"); - xml_set_end_namespace_decl_handler($parser, "end_ns"); - - $contents = ""; - - $fp = fopen("php://input", "r"); - while(!feof($fp)) { - $line = fgets($fp, 4096); - - if($app_logging) $contents .= $line; - - if(!xml_parse($parser, $line)) { - log_app("xml_parse_error", "line: $line"); - $this->error = sprintf("XML error: %s at line %d\n", - xml_error_string(xml_get_error_code($xml_parser)), - xml_get_current_line_number($xml_parser)); - log_app("xml_parse_error", $this->error); - return false; - } - } - fclose($fp); - - xml_parser_free($parser); - - log_app("AtomParser->parse()",trim($contents)); - - return true; - } - - function start_element($parser, $name, $attrs) { - - $tag = array_pop(split(":", $name)); - - array_unshift($this->ns_contexts, $this->ns_decls); - - $this->depth++; - - #print str_repeat(" ", $this->depth * $this->indent) . "start_element('$name')" ."\n"; - #print str_repeat(" ", $this->depth+1 * $this->indent) . print_r($this->ns_contexts,true) ."\n"; - - if(!empty($this->in_content)) { - $attrs_prefix = array(); - - // resolve prefixes for attributes - foreach($attrs as $key => $value) { - $attrs_prefix[$this->ns_to_prefix($key)] = $this->xml_escape($value); - } - $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix))); - if(strlen($attrs_str) > 0) { - $attrs_str = " " . $attrs_str; - } - - $xmlns_str = join(' ', array_map($this->map_xmlns_func, array_keys($this->ns_contexts[0]), array_values($this->ns_contexts[0]))); - if(strlen($xmlns_str) > 0) { - $xmlns_str = " " . $xmlns_str; - } - - // handle self-closing tags (case: a new child found right-away, no text node) - if(count($this->in_content) == 2) { - array_push($this->in_content, ">"); - } - - array_push($this->in_content, "<". $this->ns_to_prefix($name) ."{$xmlns_str}{$attrs_str}"); - } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { - $this->in_content = array(); - $this->is_xhtml = $attrs['type'] == 'xhtml'; - array_push($this->in_content, array($tag,$this->depth)); - } else if($tag == 'link') { - array_push($this->entry->links, $attrs); - } else if($tag == 'category') { - array_push($this->entry->categories, $attrs); - } - - $this->ns_decls = array(); - } - - function end_element($parser, $name) { - - $tag = array_pop(split(":", $name)); - - if(!empty($this->in_content)) { - if($this->in_content[0][0] == $tag && - $this->in_content[0][1] == $this->depth) { - array_shift($this->in_content); - if($this->is_xhtml) { - $this->in_content = array_slice($this->in_content, 2, count($this->in_content)-3); - } - $this->entry->$tag = join('',$this->in_content); - $this->in_content = array(); - } else { - $endtag = $this->ns_to_prefix($name); - if (strpos($this->in_content[count($this->in_content)-1], '<' . $endtag) !== false) { - array_push($this->in_content, "/>"); - } else { - array_push($this->in_content, ""); - } - } - } - - array_shift($this->ns_contexts); - - #print str_repeat(" ", $this->depth * $this->indent) . "end_element('$name')" ."\n"; - - $this->depth--; - } - - function start_ns($parser, $prefix, $uri) { - #print str_repeat(" ", $this->depth * $this->indent) . "starting: " . $prefix . ":" . $uri . "\n"; - array_push($this->ns_decls, array($prefix,$uri)); - } - - function end_ns($parser, $prefix) { - #print str_repeat(" ", $this->depth * $this->indent) . "ending: #" . $prefix . "#\n"; - } - - function cdata($parser, $data) { - #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n"; - if(!empty($this->in_content)) { - // handle self-closing tags (case: text node found, need to close element started) - if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) { - array_push($this->in_content, ">"); - } - array_push($this->in_content, $this->xml_escape($data)); - } - } - - function _default($parser, $data) { - # when does this gets called? - } - - - function ns_to_prefix($qname) { - $components = split(":", $qname); - $name = array_pop($components); - - if(!empty($components)) { - $ns = join(":",$components); - foreach($this->ns_contexts as $context) { - foreach($context as $mapping) { - if($mapping[1] == $ns && strlen($mapping[0]) > 0) { - return "$mapping[0]:$name"; - } - } - } - } - return $name; - } - - function xml_escape($string) - { - return str_replace(array('&','"',"'",'<','>'), - array('&','"',''','<','>'), - $string ); - } -} - -class AtomServer { - - var $ATOM_CONTENT_TYPE = 'application/atom+xml'; - var $CATEGORIES_CONTENT_TYPE = 'application/atomcat+xml'; - var $INTROSPECTION_CONTENT_TYPE = 'application/atomserv+xml'; - - var $ENTRIES_PATH = "posts"; - var $CATEGORIES_PATH = "categories"; - var $MEDIA_PATH = "attachments"; - var $ENTRY_PATH = "post"; - var $MEDIA_SINGLE_PATH = "attachment"; - - var $params = array(); - var $script_name = "app.php"; - var $media_content_types = array('image/*','audio/*','video/*'); - var $atom_content_types = array('application/atom+xml'); - - var $selectors = array(); - - // support for head - var $do_output = true; - - function AtomServer() { - - $this->script_name = array_pop(explode('/',$_SERVER['SCRIPT_NAME'])); - - $this->selectors = array( - '@/service@' => - array('GET' => 'get_service'), - '@/categories@' => - array('GET' => 'get_categories_xml'), - '@/post/(\d+)@' => - array('GET' => 'get_post', - 'PUT' => 'put_post', - 'DELETE' => 'delete_post'), - '@/posts/?([^/]+)?@' => - array('GET' => 'get_posts', - 'POST' => 'create_post'), - '@/attachments/?(\d+)?@' => - array('GET' => 'get_attachment', - 'POST' => 'create_attachment'), - '@/attachment/file/(\d+)@' => - array('GET' => 'get_file', - 'PUT' => 'put_file', - 'DELETE' => 'delete_file'), - '@/attachment/(\d+)@' => - array('GET' => 'get_attachment', - 'PUT' => 'put_attachment', - 'DELETE' => 'delete_attachment'), - ); - } - - function handle_request() { - - $path = $_SERVER['PATH_INFO']; - $method = $_SERVER['REQUEST_METHOD']; - - log_app('REQUEST',"$method $path\n================"); - - //$this->process_conditionals(); - - // exception case for HEAD (treat exactly as GET, but don't output) - if($method == 'HEAD') { - $this->do_output = false; - $method = 'GET'; - } - - // lame. - if(strlen($path) == 0 || $path == '/') { - $path = '/service'; - } - - // authenticate regardless of the operation and set the current - // user. each handler will decide if auth is required or not. - $this->authenticate(); - - // dispatch - foreach($this->selectors as $regex => $funcs) { - if(preg_match($regex, $path, $matches)) { - if(isset($funcs[$method])) { - array_shift($matches); - call_user_func_array(array(&$this,$funcs[$method]), $matches); - exit(); - } else { - // only allow what we have handlers for... - $this->not_allowed(array_keys($funcs)); - } - } - } - - // oops, nothing found - $this->not_found(); - } - - function get_service() { - log_app('function','get_service()'); - $entries_url = $this->get_entries_url(); - $categories_url = $this->get_categories_url(); - $media_url = $this->get_attachments_url(); - $accepted_content_types = join(',',$this->media_content_types); - $introspection = << - - - WordPress Posts - entry - - - - WordPress Media - $accepted_content_types - - - - -EOD; - - $this->output($introspection, $this->INTROSPECTION_CONTENT_TYPE); - } - -function get_categories_xml() { - log_app('function','get_categories_xml()'); - $home = get_bloginfo_rss('home'); - - $categories = ""; - $cats = get_categories("hierarchical=0&hide_empty=0"); - foreach ((array) $cats as $cat) { - $categories .= " cat_name) . "\" />\n"; - } - $output = << - $categories - -EOD; - $this->output($output, $this->CATEGORIES_CONTENT_TYPE); -} - - /* - * Create Post (No arguments) - */ - function create_post() { - global $current_blog; - $this->get_accepted_content_type($this->atom_content_types); - - $parser = new AtomParser(); - if(!$parser->parse()) { - $this->client_error(); - } - - $entry = $parser->entry; - - $publish = (isset($entry->draft) && trim($entry->draft) == 'yes') ? false : true; - - $cap = ($publish) ? 'publish_posts' : 'edit_posts'; - - if(!current_user_can($cap)) - $this->auth_required('Sorry, you do not have the right to edit/publish new posts.'); - - $blog_ID = (int )$current_blog->blog_id; - $post_status = ($publish) ? 'publish' : 'draft'; - $post_author = (int) $user->ID; - $post_title = $entry->title; - $post_content = $entry->content; - $post_excerpt = $entry->summary; - $post_date = current_time('mysql'); - $post_date_gmt = current_time('mysql', 1); - - $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); - - log_app('Inserting Post. Data:', print_r($post_data,true)); - - $postID = wp_insert_post($post_data); - - if (!$postID) { - $this->internal_error('Sorry, your entry could not be posted. Something wrong happened.'); - } - - $output = $this->get_entry($postID); - - log_app('function',"create_post($postID)"); - $this->created($postID, $output); - } - - function get_post($postID) { - - global $entry; - $this->set_current_entry($postID); - $output = $this->get_entry($postID); - log_app('function',"get_post($postID)"); - $this->output($output); - - } - - function put_post($postID) { - - // checked for valid content-types (atom+xml) - // quick check and exit - $this->get_accepted_content_type($this->atom_content_types); - - $parser = new AtomParser(); - if(!$parser->parse()) { - $this->bad_request(); - } - - $parsed = $parser->entry; - - // check for not found - global $entry; - $entry = $GLOBALS['entry']; - $this->set_current_entry($postID); - $this->escape($GLOBALS['entry']); - - if(!current_user_can('edit_post', $entry['ID'])) - $this->auth_required('Sorry, you do not have the right to edit this post.'); - - $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true; - - extract($entry); - - $post_title = $parsed->title; - $post_content = $parsed->content; - $post_excerpt = $parsed->summary; - - // let's not go backwards and make something draft again. - if(!$publish && $post_status == 'draft') { - $post_status = ($publish) ? 'publish' : 'draft'; - } - - $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); - - $result = wp_update_post($postdata); - - if (!$result) { - $this->internal_error('For some strange yet very annoying reason, this post could not be edited.'); - } - - log_app('function',"put_post($postID)"); - $this->ok(); - } - - function delete_post($postID) { - - // check for not found - global $entry; - $this->set_current_entry($postID); - - if(!current_user_can('edit_post', $postID)) { - $this->auth_required('Sorry, you do not have the right to delete this post.'); - } - - if ($entry['post_type'] == 'attachment') { - $this->delete_attachment($postID); - } else { - $result = wp_delete_post($postID); - - if (!$result) { - $this->internal_error('For some strange yet very annoying reason, this post could not be deleted.'); - } - - log_app('function',"delete_post($postID)"); - $this->ok(); - } - - } - - function get_attachment($postID = NULL) { - - global $entry; - if (!isset($postID)) { - $this->get_attachments(); - } else { - $this->set_current_entry($postID); - $output = $this->get_entry($postID, 'attachment'); - log_app('function',"get_attachment($postID)"); - $this->output($output); - } - } - - function create_attachment() { - global $wp, $wpdb, $wp_query, $blog_id; - - $type = $this->get_accepted_content_type(); - - if(!current_user_can('upload_files')) - $this->auth_required('You do not have permission to upload files.'); - - $fp = fopen("php://input", "rb"); - $bits = NULL; - while(!feof($fp)) { - $bits .= fread($fp, 4096); - } - fclose($fp); - - $slug = ''; - if ( isset( $_SERVER['HTTP_SLUG'] ) ) - $slug = sanitize_file_name( $_SERVER['HTTP_SLUG'] ); - elseif ( isset( $_SERVER['HTTP_TITLE'] ) ) - $slug = sanitize_file_name( $_SERVER['HTTP_TITLE'] ); - elseif ( empty( $slug ) ) // just make a random name - $slug = substr( md5( uniqid( microtime() ) ), 0, 7); - $ext = preg_replace( '|.*/([a-z]+)|', '$1', $_SERVER['CONTENT_TYPE'] ); - $slug = "$slug.$ext"; - $file = wp_upload_bits( $slug, NULL, $bits); - - log_app('wp_upload_bits returns:',print_r($file,true)); - - $url = $file['url']; - $file = $file['file']; - $filename = basename($file); - - $header = apply_filters('wp_create_file_in_uploads', $file); // replicate - - // Construct the attachment array - $attachment = array( - 'post_title' => $slug, - 'post_content' => $slug, - 'post_status' => 'attachment', - 'post_parent' => 0, - 'post_mime_type' => $type, - 'guid' => $url - ); - - // Save the data - $postID = wp_insert_attachment($attachment, $file, $post); - - if (!$postID) { - $this->internal_error('Sorry, your entry could not be posted. Something wrong happened.'); - } - - $output = $this->get_entry($postID, 'attachment'); - - $this->created($postID, $output, 'attachment'); - log_app('function',"create_attachment($postID)"); - } - - function put_attachment($postID) { - - // checked for valid content-types (atom+xml) - // quick check and exit - $this->get_accepted_content_type($this->atom_content_types); - - $parser = new AtomParser(); - if(!$parser->parse()) { - $this->bad_request(); - } - - $parsed = $parser->entry; - - // check for not found - global $entry; - $this->set_current_entry($postID); - $this->escape($entry); - - if(!current_user_can('edit_post', $entry['ID'])) - $this->auth_required('Sorry, you do not have the right to edit this post.'); - - $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true; - - extract($entry); - - $post_title = $parsed->title; - $post_content = $parsed->content; - - $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); - - $result = wp_update_post($postdata); - - if (!$result) { - $this->internal_error('For some strange yet very annoying reason, this post could not be edited.'); - } - - log_app('function',"put_attachment($postID)"); - $this->ok(); - } - - function delete_attachment($postID) { - log_app('function',"delete_attachment($postID). File '$location' deleted."); - - // check for not found - global $entry; - $this->set_current_entry($postID); - - if(!current_user_can('edit_post', $postID)) { - $this->auth_required('Sorry, you do not have the right to delete this post.'); - } - - $location = get_post_meta($entry['ID'], '_wp_attached_file', true); - - // delete file - @unlink($location); - - // delete attachment - $result = wp_delete_post($postID); - - if (!$result) { - $this->internal_error('For some strange yet very annoying reason, this post could not be deleted.'); - } - - log_app('function',"delete_attachment($postID). File '$location' deleted."); - $this->ok(); - } - - function get_file($postID) { - - // check for not found - global $entry; - $this->set_current_entry($postID); - - // then whether user can edit the specific post - if(!current_user_can('edit_post', $postID)) { - $this->auth_required('Sorry, you do not have the right to edit this post.'); - } - - $location = get_post_meta($entry['ID'], '_wp_attached_file', true); - - if(!isset($location)) - $this->internal_error('Error ocurred while accessing post metadata for file location.'); - - header('Content-Type: ' . $entry['post_mime_type']); - - $fp = fopen($location, "rb"); - while(!feof($fp)) { - echo fread($fp, 4096); - } - fclose($fp); - - log_app('function',"get_file($postID)"); - $this->ok(); - } - - function put_file($postID) { - - $type = $this->get_accepted_content_type(); - - // first check if user can upload - if(!current_user_can('upload_files')) - $this->auth_required('You do not have permission to upload files.'); - - // check for not found - global $entry; - $this->set_current_entry($postID); - - // then whether user can edit the specific post - if(!current_user_can('edit_post', $postID)) { - $this->auth_required('Sorry, you do not have the right to edit this post.'); - } - - $location = get_post_meta($entry['ID'], '_wp_attached_file', true); - - if(!isset($location)) - $this->internal_error('Error ocurred while accessing post metadata for file location.'); - - $fp = fopen("php://input", "rb"); - $localfp = fopen($location, "w+"); - while(!feof($fp)) { - fwrite($localfp,fread($fp, 4096)); - } - fclose($fp); - fclose($localfp); - - log_app('function',"put_file($postID)"); - $this->ok(); - } - - function get_entries_url($page = NULL) { - global $use_querystring; - $url = get_bloginfo('url') . '/' . $this->script_name; - if ($use_querystring) { - $url .= '?action=/' . $this->ENTRIES_PATH; - if(isset($page) && is_int($page)) { - $url .= "&eid=$page"; - } - } else { - $url .= '/' . $this->ENTRIES_PATH; - if(isset($page) && is_int($page)) { - $url .= "/$page"; - } - } - return $url; - } - - function the_entries_url($page = NULL) { - $url = $this->get_entries_url($page); - echo $url; - } - - function get_categories_url($page = NULL) { - global $use_querystring; - $url = get_bloginfo('url') . '/' . $this->script_name; - if ($use_querystring) { - $url .= '?action=/' . $this->CATEGORIES_PATH; - } else { - $url .= '/' . $this->CATEGORIES_PATH; - } - return $url; - } - - function the_categories_url() { - $url = $this->get_categories_url(); - echo $url; - } - - function get_attachments_url($page = NULL) { - global $use_querystring; - $url = get_bloginfo('url') . '/' . $this->script_name; - if ($use_querystring) { - $url .= '?action=/' . $this->MEDIA_PATH; - if(isset($page) && is_int($page)) { - $url .= "&eid=$page"; - } - } else { - $url .= '/' . $this->MEDIA_PATH; - if(isset($page) && is_int($page)) { - $url .= "/$page"; - } - } - return $url; - } - - function the_attachments_url($page = NULL) { - $url = $this->get_attachments_url($page); - echo $url; - } - - - function get_entry_url($postID = NULL) { - global $use_querystring; - if(!isset($postID)) { - global $post; - $postID = (int) $GLOBALS['post']->ID; - } - - if ($use_querystring) { - $url = get_bloginfo('url') . '/' . $this->script_name . '?action=/' . $this->ENTRY_PATH . "&eid=$postID"; - } else { - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->ENTRY_PATH . "/$postID"; - } - - log_app('function',"get_entry_url() = $url"); - return $url; - } - - function the_entry_url($postID = NULL) { - $url = $this->get_entry_url($postID); - echo $url; - } - - function get_media_url($postID = NULL) { - global $use_querystring; - if(!isset($postID)) { - global $post; - $postID = (int) $GLOBALS['post']->ID; - } - - if ($use_querystring) { - $url = get_bloginfo('url') . '/' . $this->script_name . '?action=/' . $this->MEDIA_SINGLE_PATH ."&eid=$postID"; - } else { - $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_SINGLE_PATH ."/$postID"; - } - - log_app('function',"get_media_url() = $url"); - return $url; - } - - function the_media_url($postID = NULL) { - $url = $this->get_media_url($postID); - echo $url; - } - - function set_current_entry($postID) { - global $entry; - log_app('function',"set_current_entry($postID)"); - - if(!isset($postID)) { - // $this->bad_request(); - $this->not_found(); - } - - $entry = wp_get_single_post($postID,ARRAY_A); - - if(!isset($entry) || !isset($entry['ID'])) - $this->not_found(); - - return; - } - - function get_posts_count() { - global $wpdb; - log_app('function',"get_posts_count()"); - return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_date_gmt < '" . gmdate("Y-m-d H:i:s",time()) . "'"); - } - - - function get_posts($page = 1, $post_type = 'post') { - log_app('function',"get_posts($page, '$post_type')"); - $feed = $this->get_feed($page, $post_type); - $this->output($feed); - } - - function get_attachments($page = 1, $post_type = 'attachment') { - log_app('function',"get_attachments($page, '$post_type')"); - $feed = $this->get_feed($page, $post_type); - $this->output($feed); - } - - function get_feed($page = 1, $post_type = 'post') { - global $post, $wp, $wp_query, $posts, $wpdb, $blog_id, $post_cache; - log_app('function',"get_feed($page, '$post_type')"); - ob_start(); - - if(!isset($page)) { - $page = 1; - } - $page = (int) $page; - - $count = get_option('posts_per_rss'); - $query = "paged=$page&posts_per_page=$count&order=DESC"; - if($post_type == 'attachment') { - $query .= "&post_type=$post_type"; - } - query_posts($query); - $post = $GLOBALS['post']; - $posts = $GLOBALS['posts']; - $wp = $GLOBALS['wp']; - $wp_query = $GLOBALS['wp_query']; - $wpdb = $GLOBALS['wpdb']; - $blog_id = (int) $GLOBALS['blog_id']; - $post_cache = $GLOBALS['post_cache']; - - - $total_count = $this->get_posts_count(); - $last_page = (int) ceil($total_count / $count); - $next_page = (($page + 1) > $last_page) ? NULL : $page + 1; - $prev_page = ($page - 1) < 1 ? NULL : $page - 1; - $last_page = ((int)$last_page == 1 || (int)$last_page == 0) ? NULL : (int) $last_page; -?> -the_entries_url() ?> - -<?php bloginfo_rss('name') ?> - - - - - - - - - - -Copyright -WordPress.com Atom API - - - ID); ?> - <![CDATA[<?php the_title() ?>]]> - - - - post_status == 'draft' ? 'yes' : 'no') ?> - - - - - - - - - post_status == 'attachment') { ?> - - - - - - - - - ]]> - post_content ) ) : ?> - ]]> - - - - - - - ID); ?> - <![CDATA[<?php the_title_rss() ?>]]> - - - - - post_status == 'draft' ? 'yes' : 'no') ?> - - - - - - -post_type == 'attachment') { ?> - - - - - - - - - - ]]> -post_content ) ) : ?> - ]]> - - -auth_required("Access Denied."); - endif; - ob_end_clean(); - - log_app('get_entry returning:',$entry); - return $entry; - } - - function ok() { - log_app('Status','200: OK'); - header('Content-Type: text/plain'); - status_header('200'); - exit; - } - - function no_content() { - log_app('Status','204: No Content'); - header('Content-Type: text/plain'); - status_header('204'); - echo "Deleted."; - exit; - } - - function internal_error($msg = 'Internal Server Error') { - log_app('Status','500: Server Error'); - header('Content-Type: text/plain'); - status_header('500'); - echo $msg; - exit; - } - - function bad_request() { - log_app('Status','400: Bad Request'); - header('Content-Type: text/plain'); - status_header('400'); - exit; - } - - function length_required() { - log_app('Status','411: Length Required'); - header("HTTP/1.1 411 Length Required"); - header('Content-Type: text/plain'); - status_header('411'); - exit; - } - - function invalid_media() { - log_app('Status','415: Unsupported Media Type'); - header("HTTP/1.1 415 Unsupported Media Type"); - header('Content-Type: text/plain'); - exit; - } - - function not_found() { - log_app('Status','404: Not Found'); - header('Content-Type: text/plain'); - status_header('404'); - exit; - } - - function not_allowed($allow) { - log_app('Status','405: Not Allowed'); - header('Allow: ' . join(',', $allow)); - status_header('405'); - exit; - } - - function client_error($msg = 'Client Error') { - log_app('Status','400: Client Errir'); - header('Content-Type: text/plain'); - status_header('400'); - exit; - } - - function created($post_ID, $content, $post_type = 'post') { - global $use_querystring; - log_app('created()::$post_ID',"$post_ID, $post_type"); - $edit = $this->get_entry_url($post_ID); - switch($post_type) { - case 'post': - $ctloc = $this->get_entry_url($post_ID); - break; - case 'attachment': - if ($use_querystring) { - $edit = get_bloginfo('url') . '/' . $this->script_name . "?action=/attachments&eid=$post_ID"; - } else { - $edit = get_bloginfo('url') . '/' . $this->script_name . "/attachments/$post_ID"; - } - break; - } - header('Content-Type: application/atom+xml'); - if(isset($ctloc)) - header('Content-Location: ' . $ctloc); - header('Location: ' . $edit); - status_header('201'); - echo $content; - exit; - } - - function auth_required($msg) { - log_app('Status','401: Auth Required'); - nocache_headers(); - header('WWW-Authenticate: Basic realm="WordPress Atom Protocol"'); - header('WWW-Authenticate: Form action="' . get_option('siteurl') . '/wp-login.php"', false); - header("HTTP/1.1 401 $msg"); - header('Status: ' . $msg); - header('Content-Type: plain/text'); - echo $msg; - exit; - } - - function output($xml, $ctype = "application/atom+xml") { - status_header('200'); - $xml = ''."\n".$xml; - header('Connection: close'); - header('Content-Length: '. strlen($xml)); - header('Content-Type: ' . $ctype); - header('Content-Disposition: attachment; filename=atom.xml'); - header('Date: '. date('r')); - if($this->do_output) - echo $xml; - log_app('function', "output:\n$xml"); - exit; - } - - function escape(&$array) { - global $wpdb; - - foreach ($array as $k => $v) { - if (is_array($v)) { - $this->escape($array[$k]); - } else if (is_object($v)) { - //skip - } else { - $array[$k] = $wpdb->escape($v); - } - } - } - - - - /* - * Access credential through various methods and perform login - */ - function authenticate() { - $login_data = array(); - $already_md5 = false; - - log_app("authenticate()",print_r($_ENV, true)); - - // if using mod_rewrite/ENV hack - // http://www.besthostratings.com/articles/http-auth-php-cgi.html - if(isset($_SERVER['HTTP_AUTHORIZATION'])) { - list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = - explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); - } - - // If Basic Auth is working... - if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { - $login_data = array('login' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']); - } else { - // else, do cookie-based authentication - if (function_exists('wp_get_cookie_login')) { - $login_data = wp_get_cookie_login(); - $already_md5 = true; - } - } - - // call wp_login and set current user - if (!empty($login_data) && wp_login($login_data['login'], $login_data['password'], $already_md5)) { - $current_user = new WP_User(0, $login_data['login']); - wp_set_current_user($current_user->ID); - log_app("authenticate()",$login_data['login']); - } - } - - function get_accepted_content_type($types = NULL) { - - if(!isset($types)) { - $types = $this->media_content_types; - } - - if(!isset($_SERVER['CONTENT_LENGTH']) || !isset($_SERVER['CONTENT_TYPE'])) { - $this->length_required(); - } - - $type = $_SERVER['CONTENT_TYPE']; - list($type,$subtype) = explode('/',$type); - list($subtype) = explode(";",$subtype); // strip MIME parameters - log_app("get_accepted_content_type", "type=$type, subtype=$subtype"); - - foreach($types as $t) { - list($acceptedType,$acceptedSubtype) = explode('/',$t); - if($acceptedType == '*' || $acceptedType == $type) { - if($acceptedSubtype == '*' || $acceptedSubtype == $subtype) - return $type; - } - } - - $this->invalid_media(); - } - - - - function process_conditionals() { - - if(empty($this->params)) return; - if($_SERVER['REQUEST_METHOD'] == 'DELETE') return; - - switch($this->params[0]) { - case $this->ENTRY_PATH: - global $post; - $post = wp_get_single_post($this->params[1]); - $wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true); - $post = NULL; - break; - case $this->ENTRIES_PATH: - $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; - break; - default: - return; - } - $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'])) - $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); - else - $client_etag = false; - - $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']); - // If string is empty, return 0. If not, attempt to parse into a timestamp - $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; - - // Make a timestamp for our most recent modification... - $wp_modified_timestamp = strtotime($wp_last_modified); - - if ( ($client_last_modified && $client_etag) ? - (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : - (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { - status_header( 304 ); - exit; - } - } - - -} - -$server = new AtomServer(); -$server->handle_request(); - -?> diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 2ad2469..ad5064f 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -151,6 +151,31 @@ case 'add-cat' : // From Manage->Categories ) ); $x->send(); break; +case 'add-comment' : + if ( !current_user_can( 'edit_post', $id ) ) + die('-1'); + $search = isset($_POST['s']) ? $_POST['s'] : false; + $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25; + + list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); + + if ( !$comments ) + die('1'); + $x = new WP_Ajax_Response(); + foreach ( (array) $comments as $comment ) { + get_comment( $comment ); + ob_start(); + _wp_comment_list_item( $comment->comment_ID ); + $comment_list_item = ob_get_contents(); + ob_end_clean(); + $x->add( array( + 'what' => 'comment', + 'id' => $comment->comment_ID, + 'data' => $comment_list_item + ) ); + } + $x->send(); + break; case 'add-meta' : if ( !current_user_can( 'edit_post', $id ) ) die('-1'); diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php index de90ad7..24e2388 100644 --- a/wp-admin/admin-db.php +++ b/wp-admin/admin-db.php @@ -125,6 +125,11 @@ function wp_insert_category($catarr) { else $links_private = 0; + + // Let's check if we have this category already, if so just do an update + if ( !$update && $cat_ID = category_object_exists( $category_nicename ) ) + $update = true; + if (!$update) { $maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" ); $cat_ID = mt_rand( $maxcat+100, $maxcat+4000 ); @@ -153,6 +158,11 @@ function wp_insert_category($catarr) { clean_category_cache($cat_ID); + if ($update) + do_action('edited_category', $cat_ID); + else + do_action('created_category', $cat_ID); + return $cat_ID; } @@ -245,6 +255,14 @@ function wp_create_categories($categories, $post_id = '') { return $cat_ids; } +function category_object_exists($cat_name) { + global $wpdb; + if (!$category_nicename = sanitize_title($cat_name)) + return 0; + + return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); +} + function category_exists($cat_name) { global $wpdb; if (!$category_nicename = sanitize_title($cat_name)) @@ -419,6 +437,8 @@ function wp_delete_link($link_id) { $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'"); return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'"); + + do_action('deleted_link', $link_id); } function wp_get_link_cats($link_ID = 0) { diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index 8e30631..40a3e8c 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -2,7 +2,7 @@ diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 7b9507c..10f8eeb 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -490,7 +490,7 @@ function edit_user( $user_id = 0 ) { 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 = clean_url( trim( $_POST['url'] )); $user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; } if ( isset( $_POST['first_name'] )) @@ -702,6 +702,7 @@ function get_nested_categories( $default = 0, $parent = 0 ) { } } + $result = apply_filters('get_nested_categories', $result); usort( $result, 'sort_cats' ); return $result; @@ -774,6 +775,8 @@ function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { if (!$categories ) $categories = get_categories( 'hide_empty=0' ); + $children = _get_category_hierarchy(); + if ( $categories ) { ob_start(); foreach ( $categories as $category ) { @@ -783,7 +786,8 @@ function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { } if ( $category->category_parent == $parent) { echo "\t" . _cat_row( $category, $level ); - cat_rows( $category->cat_ID, $level +1, $categories ); + if ( isset($children[$category->cat_ID]) ) + cat_rows( $category->cat_ID, $level +1, $categories ); } } $output = ob_get_contents(); @@ -815,8 +819,8 @@ function _cat_row( $category, $level, $name_override = false ) { $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; - $category->category_count = number_format( $category->category_count ); - $category->link_count = number_format( $category->link_count ); + $category->category_count = number_format_i18n( $category->category_count ); + $category->link_count = number_format_i18n( $category->link_count ); $posts_count = ( $category->category_count > 0 ) ? "$category->category_count" : $category->category_count; return " $category->cat_ID @@ -898,6 +902,68 @@ function user_row( $user_object, $style = '' ) { return $r; } +function _wp_get_comment_list( $s = false, $start, $num ) { + global $wpdb; + + $start = (int) $start; + $num = (int) $num; + + if ( $s ) { + $s = $wpdb->escape($s); + $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE + (comment_author LIKE '%$s%' OR + comment_author_email LIKE '%$s%' OR + comment_author_url LIKE ('%$s%') OR + comment_author_IP LIKE ('%$s%') OR + comment_content LIKE ('%$s%') ) AND + comment_approved != 'spam' + ORDER BY comment_date DESC LIMIT $start, $num"); + } else { + $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" ); + } + + $total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); + + return array($comments, $total); +} + +function _wp_comment_list_item( $id, $alt = 0 ) { + global $authordata, $comment, $wpdb; + $id = (int) $id; + $comment =& get_comment( $id ); + $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 ) + $class .= ' unapproved'; + if ( $alt % 2 ) + $class .= ' alternate'; + echo "
  • "; +?> +

    comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | |

    + + + +

    — [ +comment_post_ID) ) { + echo " " . __('Edit') . ''; + echo ' | comment_author)) . "', theCommentList );\">" . __('Delete') . ' '; + if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { + echo ' | ' . __('Unapprove') . ' '; + echo ' | ' . __('Approve') . ' '; + } + echo " | comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . " "; +} +$post = get_post($comment->comment_post_ID); +$post_title = wp_specialchars( $post->post_title, 'double' ); +$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; +?> + ] —

    +
  • +' . trim( $author_name[1] ) . ''; } - 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); } function get_plugins() { @@ -1701,20 +1768,20 @@ function get_plugins() { $plugins_dir = @ dir( $plugin_root); if ( $plugins_dir ) { while (($file = $plugins_dir->read() ) !== false ) { - if ( preg_match( '|^\.+$|', $file )) + if ( substr($file, 0, 1) == '.' ) 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 ( substr($subfile, 0, 1) == '.' ) continue; - if ( preg_match( '|\.php$|', $subfile )) + if ( substr($subfile, -4) == '.php' ) $plugin_files[] = "$file/$subfile"; } } } else { - if ( preg_match( '|\.php$|', $file )) + if ( substr($file, -4) == '.php' ) $plugin_files[] = $file; } } @@ -1795,7 +1862,7 @@ function register_importer( $id, $name, $description, $callback ) { function get_importers() { global $wp_importers; - + uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); return $wp_importers; } @@ -1878,8 +1945,11 @@ function wp_handle_upload( &$file, $overrides = false ) { extract( $wp_filetype ); - if ( !$type || !$ext ) + if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); + + if ( !$ext ) + $ext = strrchr($file['name'], '.'); } // A writable uploads dir will pass this test. Again, there's no point overriding this one. @@ -1950,6 +2020,7 @@ function wp_import_upload_form( $action ) { ?>

    + ( ) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 9f6402b..d6ff2ef 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -13,7 +13,7 @@ get_admin_page_title(); ?> -> + > <?php bloginfo('name') ?> › <?php echo wp_specialchars( strip_tags( $title ) ); ?> — WordPress @@ -44,7 +44,7 @@ do_action('admin_head');

    %s.'), $user_identity) ?> [, ]

    diff --git a/wp-admin/cat.js b/wp-admin/cat.js index ab94d4c..e93adfc 100644 --- a/wp-admin/cat.js +++ b/wp-admin/cat.js @@ -4,7 +4,7 @@ function newCatAddIn() { var jaxcat = $('jaxcat'); if ( !jaxcat ) return false; - Element.update(jaxcat,'' + catL10n.how + ''); + Element.update(jaxcat,'' + catL10n.how + ''); $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); }; $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); }; } diff --git a/wp-admin/categories.js b/wp-admin/categories.js index 8951df0..515d530 100644 --- a/wp-admin/categories.js +++ b/wp-admin/categories.js @@ -2,7 +2,7 @@ addLoadEvent(function() { if (!theList.theList) return false; document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; theList.addComplete = function(what, where, update, transport) { - var name = getNodeValue(transport.responseXML, 'name'); + var name = getNodeValue(transport.responseXML, 'name').unescapeHTML(); var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id'); var options = document.forms['addcat'].category_parent.options; options[options.length] = new Option(name, id); diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 5e77e0f..40bdbf9 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -118,6 +118,7 @@ cat_rows(); + comment_author_url ) { ?> -comment_author_url; ?> +comment_author_url'>$comment->comment_author_url"; ?> diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index 5daad1e..d18ed87 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -23,6 +23,7 @@ class Custom_Image_Header { function js() { if ( isset( $_POST['textcolor'] ) ) { + check_admin_referer('custom-header'); if ( 'blank' == $_POST['textcolor'] ) { set_theme_mod('header_textcolor', 'blank'); } else { @@ -31,8 +32,10 @@ class Custom_Image_Header { set_theme_mod('header_textcolor', $color); } } - if ( isset($_POST['resetheader']) ) + if ( isset($_POST['resetheader']) ) { + check_admin_referer('custom-header'); remove_theme_mods(); + } ?> +≡' + : ''; + + $output = '
  • %2$s
  • '; + + printf( $output, $sanitized_name, $wp_registered_widgets[$name]['name'] . $popper ); +} + +$title = __( 'Widgets' ); +$parent_file = 'themes.php'; + +require_once 'admin-header.php'; + +if ( count( $wp_registered_sidebars ) < 1 ) { +?> +
    +

    + +

    follow these instructions.' ); /* TODO: article on codex */; ?>

    +
    + $sidebar ) { + $postindex = $index . 'order'; + + parse_str( $_POST[$postindex], $order ); + + $new_order = $order[$index]; + + if ( is_array( $new_order ) ) { + foreach ( $new_order as $sanitized_name ) { + foreach ( $wp_registered_widgets as $name => $widget ) { + if ( $sanitized_name == $widget['id'] ) { + $sidebars_widgets[$index][] = $name; + } + } + } + } + } + + wp_set_sidebars_widgets( $sidebars_widgets ); + break; + } +} + +ksort( $wp_registered_widgets ); + +$inactive_widgets = array(); + +foreach ( $wp_registered_widgets as $name => $widget ) { + $is_active = false; + + foreach ( $wp_registered_sidebars as $index => $sidebar ) { + if ( is_array( $sidebars_widgets[$index] ) && in_array( $name, $sidebars_widgets[$index] ) ) { + $is_active = true; + break; + } + } + + if ( !$is_active ) { + $inactive_widgets[] = $name; + } +} + +$containers = array( 'palette' ); + +foreach ( $wp_registered_sidebars as $index => $sidebar ) { + $containers[] = $index; +} + +$c_string = ''; + +foreach ( $containers as $container ) { + $c_string .= '"' . $container . '",'; +} + +$c_string = substr( $c_string, 0, -1 ); + +if ( isset( $_POST['action'] ) ) { +?> +
    +

    View site »' ), get_bloginfo( 'url' ) . '/' ); ?>

    +
    + +
    +

    + +

    + + +

    + +

    +
    + $sidebar ) { + ?> + + +
    +

    + +
    + +

    + +
    +
    + +
      + +
    +
    + + +
    + +
    + +
    +

    + +
      + +
    • +
    +
    + + + +

    + + + +

    + +
    + $widget ) { ?> + + +
    + + +
    +
    + +
    + + + + diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 6de69f4..14c93a2 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -120,7 +120,6 @@ a:visited { } a:hover { -/* border-bottom: 1px solid #3a75ae;*/ color: #069; } @@ -132,7 +131,7 @@ body { } body, td { - font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana; + font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; } fieldset { @@ -170,10 +169,10 @@ form, label input { } h2 { - border-bottom: .5em solid #e5f3ff; color: #333; - font: normal 32px/5px serif; + font: normal 32px serif; margin: 5px 10px; + background: url( images/heading-bg.gif ) repeat-x bottom; } img, #footer a { @@ -437,7 +436,7 @@ form#upload #post_content { } .wrap h2 { - margin: .4em 0 .5em; + margin: 0 0 .5em; clear: both; } @@ -538,7 +537,7 @@ input.disabled, textarea.disabled { border: none; } -#postdiv, #titlediv, #guiddiv { +#postdiv, #titlediv, #guiddiv, #tagdiv { margin: 0 8px 0 0; padding: 0; } @@ -554,11 +553,11 @@ input.disabled, textarea.disabled { } #postdivrich #content { - padding: .7em; + padding: 5px; line-height: 140%; } -#titlediv input, #guiddiv input { +#titlediv input, #guiddiv input, #tagdiv input { margin: 0; width: 100%; } @@ -629,7 +628,7 @@ input.delete:hover { #title { font-size: 1.7em; - padding: 4px; + padding: 4px 3px; } #postexcerpt div, #attachmentlinks div { @@ -912,17 +911,13 @@ input.delete:hover { } #zeitgeist h2, fieldset legend a { - border-bottom: none; + background: none; } * html #zeitgeist h2 { padding-top: 10px; } -#zeitgeist h2 { - margin-top: .4em; -} - #zeitgeist h3 { border-bottom: 1px solid #ccc; font-size: 16px; @@ -1332,3 +1327,10 @@ a.page-numbers:hover { font-weight: bold; margin: 0 6px; } + +a.view-link { + position: absolute; + right: 5%; + margin-right: 220px; + text-decoration:underline; +} diff --git a/wp-app.php b/wp-app.php new file mode 100644 index 0000000..078667d --- /dev/null +++ b/wp-app.php @@ -0,0 +1,1260 @@ +ID) ) + return $current_user; + + $current_user = new WP_User($id, $name); + + return $current_user; +} +endif; + +function wa_posts_where_include_drafts_filter($where) { + $where = ereg_replace("post_author = ([0-9]+) AND post_status != 'draft'","post_author = \\1 AND post_status = 'draft'", $where); + return $where; +} +add_filter('posts_where', 'wa_posts_where_include_drafts_filter'); + +class AtomEntry { + var $links = array(); + var $categories = array(); +} + +class AtomParser { + + var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights'); + var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft'); + + var $depth = 0; + var $indent = 2; + var $in_content; + var $ns_contexts = array(); + var $ns_decls = array(); + var $is_xhtml = false; + var $skipped_div = false; + + var $entry; + + function AtomParser() { + + $this->entry = new AtomEntry(); + $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";'); + $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";'); + } + + function parse() { + + global $app_logging; + array_unshift($this->ns_contexts, array()); + + $parser = xml_parser_create_ns(); + xml_set_object($parser, $this); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); + xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); + xml_set_character_data_handler($parser, "cdata"); + xml_set_default_handler($parser, "_default"); + xml_set_start_namespace_decl_handler($parser, "start_ns"); + xml_set_end_namespace_decl_handler($parser, "end_ns"); + + $contents = ""; + + $fp = fopen("php://input", "r"); + while(!feof($fp)) { + $line = fgets($fp, 4096); + + if($app_logging) $contents .= $line; + + if(!xml_parse($parser, $line)) { + log_app("xml_parse_error", "line: $line"); + $this->error = sprintf(__('XML error: %s at line %d')."\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser)); + log_app("xml_parse_error", $this->error); + return false; + } + } + fclose($fp); + + xml_parser_free($parser); + + log_app("AtomParser->parse()",trim($contents)); + + return true; + } + + function start_element($parser, $name, $attrs) { + + $tag = array_pop(split(":", $name)); + + array_unshift($this->ns_contexts, $this->ns_decls); + + $this->depth++; + + #print str_repeat(" ", $this->depth * $this->indent) . "start_element('$name')" ."\n"; + #print str_repeat(" ", $this->depth+1 * $this->indent) . print_r($this->ns_contexts,true) ."\n"; + + if(!empty($this->in_content)) { + $attrs_prefix = array(); + + // resolve prefixes for attributes + foreach($attrs as $key => $value) { + $attrs_prefix[$this->ns_to_prefix($key)] = $this->xml_escape($value); + } + $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix))); + if(strlen($attrs_str) > 0) { + $attrs_str = " " . $attrs_str; + } + + $xmlns_str = join(' ', array_map($this->map_xmlns_func, array_keys($this->ns_contexts[0]), array_values($this->ns_contexts[0]))); + if(strlen($xmlns_str) > 0) { + $xmlns_str = " " . $xmlns_str; + } + + // handle self-closing tags (case: a new child found right-away, no text node) + if(count($this->in_content) == 2) { + array_push($this->in_content, ">"); + } + + array_push($this->in_content, "<". $this->ns_to_prefix($name) ."{$xmlns_str}{$attrs_str}"); + } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { + $this->in_content = array(); + $this->is_xhtml = $attrs['type'] == 'xhtml'; + array_push($this->in_content, array($tag,$this->depth)); + } else if($tag == 'link') { + array_push($this->entry->links, $attrs); + } else if($tag == 'category') { + array_push($this->entry->categories, $attrs); + } + + $this->ns_decls = array(); + } + + function end_element($parser, $name) { + + $tag = array_pop(split(":", $name)); + + if(!empty($this->in_content)) { + if($this->in_content[0][0] == $tag && + $this->in_content[0][1] == $this->depth) { + array_shift($this->in_content); + if($this->is_xhtml) { + $this->in_content = array_slice($this->in_content, 2, count($this->in_content)-3); + } + $this->entry->$tag = join('',$this->in_content); + $this->in_content = array(); + } else { + $endtag = $this->ns_to_prefix($name); + if (strpos($this->in_content[count($this->in_content)-1], '<' . $endtag) !== false) { + array_push($this->in_content, "/>"); + } else { + array_push($this->in_content, ""); + } + } + } + + array_shift($this->ns_contexts); + + #print str_repeat(" ", $this->depth * $this->indent) . "end_element('$name')" ."\n"; + + $this->depth--; + } + + function start_ns($parser, $prefix, $uri) { + #print str_repeat(" ", $this->depth * $this->indent) . "starting: " . $prefix . ":" . $uri . "\n"; + array_push($this->ns_decls, array($prefix,$uri)); + } + + function end_ns($parser, $prefix) { + #print str_repeat(" ", $this->depth * $this->indent) . "ending: #" . $prefix . "#\n"; + } + + function cdata($parser, $data) { + #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n"; + if(!empty($this->in_content)) { + // handle self-closing tags (case: text node found, need to close element started) + if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) { + array_push($this->in_content, ">"); + } + array_push($this->in_content, $this->xml_escape($data)); + } + } + + function _default($parser, $data) { + # when does this gets called? + } + + + function ns_to_prefix($qname) { + $components = split(":", $qname); + $name = array_pop($components); + + if(!empty($components)) { + $ns = join(":",$components); + foreach($this->ns_contexts as $context) { + foreach($context as $mapping) { + if($mapping[1] == $ns && strlen($mapping[0]) > 0) { + return "$mapping[0]:$name"; + } + } + } + } + return $name; + } + + function xml_escape($string) + { + return str_replace(array('&','"',"'",'<','>'), + array('&','"',''','<','>'), + $string ); + } +} + +class AtomServer { + + var $ATOM_CONTENT_TYPE = 'application/atom+xml'; + var $CATEGORIES_CONTENT_TYPE = 'application/atomcat+xml'; + var $INTROSPECTION_CONTENT_TYPE = 'application/atomserv+xml'; + + var $ENTRIES_PATH = "posts"; + var $CATEGORIES_PATH = "categories"; + var $MEDIA_PATH = "attachments"; + var $ENTRY_PATH = "post"; + var $MEDIA_SINGLE_PATH = "attachment"; + + var $params = array(); + var $script_name = "wp-app.php"; + var $media_content_types = array('image/*','audio/*','video/*'); + var $atom_content_types = array('application/atom+xml'); + + var $selectors = array(); + + // support for head + var $do_output = true; + + function AtomServer() { + + $this->script_name = array_pop(explode('/',$_SERVER['SCRIPT_NAME'])); + + $this->selectors = array( + '@/service@' => + array('GET' => 'get_service'), + '@/categories@' => + array('GET' => 'get_categories_xml'), + '@/post/(\d+)@' => + array('GET' => 'get_post', + 'PUT' => 'put_post', + 'DELETE' => 'delete_post'), + '@/posts/?([^/]+)?@' => + array('GET' => 'get_posts', + 'POST' => 'create_post'), + '@/attachments/?(\d+)?@' => + array('GET' => 'get_attachment', + 'POST' => 'create_attachment'), + '@/attachment/file/(\d+)@' => + array('GET' => 'get_file', + 'PUT' => 'put_file', + 'DELETE' => 'delete_file'), + '@/attachment/(\d+)@' => + array('GET' => 'get_attachment', + 'PUT' => 'put_attachment', + 'DELETE' => 'delete_attachment'), + ); + } + + function handle_request() { + + $path = $_SERVER['PATH_INFO']; + $method = $_SERVER['REQUEST_METHOD']; + + log_app('REQUEST',"$method $path\n================"); + + //$this->process_conditionals(); + + // exception case for HEAD (treat exactly as GET, but don't output) + if($method == 'HEAD') { + $this->do_output = false; + $method = 'GET'; + } + + // lame. + if(strlen($path) == 0 || $path == '/') { + $path = '/service'; + } + + // authenticate regardless of the operation and set the current + // user. each handler will decide if auth is required or not. + $this->authenticate(); + + // dispatch + foreach($this->selectors as $regex => $funcs) { + if(preg_match($regex, $path, $matches)) { + if(isset($funcs[$method])) { + array_shift($matches); + call_user_func_array(array(&$this,$funcs[$method]), $matches); + exit(); + } else { + // only allow what we have handlers for... + $this->not_allowed(array_keys($funcs)); + } + } + } + + // oops, nothing found + $this->not_found(); + } + + function get_service() { + log_app('function','get_service()'); + $entries_url = $this->get_entries_url(); + $categories_url = $this->get_categories_url(); + $media_url = $this->get_attachments_url(); + $accepted_content_types = join(',',$this->media_content_types); + $introspection = << + + + WordPress Posts + entry + + + + WordPress Media + $accepted_content_types + + + + +EOD; + + $this->output($introspection, $this->INTROSPECTION_CONTENT_TYPE); + } + +function get_categories_xml() { + log_app('function','get_categories_xml()'); + $home = get_bloginfo_rss('home'); + + $categories = ""; + $cats = get_categories("hierarchical=0&hide_empty=0"); + foreach ((array) $cats as $cat) { + $categories .= " cat_name) . "\" />\n"; + } + $output = << + $categories + +EOD; + $this->output($output, $this->CATEGORIES_CONTENT_TYPE); +} + + /* + * Create Post (No arguments) + */ + function create_post() { + global $blog_id; + $this->get_accepted_content_type($this->atom_content_types); + + $parser = new AtomParser(); + if(!$parser->parse()) { + $this->client_error(); + } + + $entry = $parser->entry; + + $publish = (isset($entry->draft) && trim($entry->draft) == 'yes') ? false : true; + + $cap = ($publish) ? 'publish_posts' : 'edit_posts'; + + if(!current_user_can($cap)) + $this->auth_required('Sorry, you do not have the right to edit/publish new posts.'); + + $blog_ID = (int ) $blog_id; + $post_status = ($publish) ? 'publish' : 'draft'; + $post_author = (int) $user->ID; + $post_title = $entry->title; + $post_content = $entry->content; + $post_excerpt = $entry->summary; + $post_date = current_time('mysql'); + $post_date_gmt = current_time('mysql', 1); + + $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); + + log_app('Inserting Post. Data:', print_r($post_data,true)); + + $postID = wp_insert_post($post_data); + + if (!$postID) { + $this->internal_error('Sorry, your entry could not be posted. Something wrong happened.'); + } + + $output = $this->get_entry($postID); + + log_app('function',"create_post($postID)"); + $this->created($postID, $output); + } + + function get_post($postID) { + + global $entry; + $this->set_current_entry($postID); + $output = $this->get_entry($postID); + log_app('function',"get_post($postID)"); + $this->output($output); + + } + + function put_post($postID) { + + // checked for valid content-types (atom+xml) + // quick check and exit + $this->get_accepted_content_type($this->atom_content_types); + + $parser = new AtomParser(); + if(!$parser->parse()) { + $this->bad_request(); + } + + $parsed = $parser->entry; + + // check for not found + global $entry; + $entry = $GLOBALS['entry']; + $this->set_current_entry($postID); + $this->escape($GLOBALS['entry']); + + if(!current_user_can('edit_post', $entry['ID'])) + $this->auth_required('Sorry, you do not have the right to edit this post.'); + + $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true; + + extract($entry); + + $post_title = $parsed->title; + $post_content = $parsed->content; + $post_excerpt = $parsed->summary; + + // let's not go backwards and make something draft again. + if(!$publish && $post_status == 'draft') { + $post_status = ($publish) ? 'publish' : 'draft'; + } + + $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); + + $result = wp_update_post($postdata); + + if (!$result) { + $this->internal_error('For some strange yet very annoying reason, this post could not be edited.'); + } + + log_app('function',"put_post($postID)"); + $this->ok(); + } + + function delete_post($postID) { + + // check for not found + global $entry; + $this->set_current_entry($postID); + + if(!current_user_can('edit_post', $postID)) { + $this->auth_required('Sorry, you do not have the right to delete this post.'); + } + + if ($entry['post_type'] == 'attachment') { + $this->delete_attachment($postID); + } else { + $result = wp_delete_post($postID); + + if (!$result) { + $this->internal_error('For some strange yet very annoying reason, this post could not be deleted.'); + } + + log_app('function',"delete_post($postID)"); + $this->ok(); + } + + } + + function get_attachment($postID = NULL) { + + global $entry; + if (!isset($postID)) { + $this->get_attachments(); + } else { + $this->set_current_entry($postID); + $output = $this->get_entry($postID, 'attachment'); + log_app('function',"get_attachment($postID)"); + $this->output($output); + } + } + + function create_attachment() { + global $wp, $wpdb, $wp_query, $blog_id; + + $type = $this->get_accepted_content_type(); + + if(!current_user_can('upload_files')) + $this->auth_required('You do not have permission to upload files.'); + + $fp = fopen("php://input", "rb"); + $bits = NULL; + while(!feof($fp)) { + $bits .= fread($fp, 4096); + } + fclose($fp); + + $slug = ''; + if ( isset( $_SERVER['HTTP_SLUG'] ) ) + $slug = sanitize_file_name( $_SERVER['HTTP_SLUG'] ); + elseif ( isset( $_SERVER['HTTP_TITLE'] ) ) + $slug = sanitize_file_name( $_SERVER['HTTP_TITLE'] ); + elseif ( empty( $slug ) ) // just make a random name + $slug = substr( md5( uniqid( microtime() ) ), 0, 7); + $ext = preg_replace( '|.*/([a-z]+)|', '$1', $_SERVER['CONTENT_TYPE'] ); + $slug = "$slug.$ext"; + $file = wp_upload_bits( $slug, NULL, $bits); + + log_app('wp_upload_bits returns:',print_r($file,true)); + + $url = $file['url']; + $file = $file['file']; + $filename = basename($file); + + $header = apply_filters('wp_create_file_in_uploads', $file); // replicate + + // Construct the attachment array + $attachment = array( + 'post_title' => $slug, + 'post_content' => $slug, + 'post_status' => 'attachment', + 'post_parent' => 0, + 'post_mime_type' => $type, + 'guid' => $url + ); + + // Save the data + $postID = wp_insert_attachment($attachment, $file, $post); + + if (!$postID) { + $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); + } + + $output = $this->get_entry($postID, 'attachment'); + + $this->created($postID, $output, 'attachment'); + log_app('function',"create_attachment($postID)"); + } + + function put_attachment($postID) { + + // checked for valid content-types (atom+xml) + // quick check and exit + $this->get_accepted_content_type($this->atom_content_types); + + $parser = new AtomParser(); + if(!$parser->parse()) { + $this->bad_request(); + } + + $parsed = $parser->entry; + + // check for not found + global $entry; + $this->set_current_entry($postID); + $this->escape($entry); + + if(!current_user_can('edit_post', $entry['ID'])) + $this->auth_required(__('Sorry, you do not have the right to edit this post.')); + + $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true; + + extract($entry); + + $post_title = $parsed->title; + $post_content = $parsed->content; + + $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); + + $result = wp_update_post($postdata); + + if (!$result) { + $this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.')); + } + + log_app('function',"put_attachment($postID)"); + $this->ok(); + } + + function delete_attachment($postID) { + log_app('function',"delete_attachment($postID). File '$location' deleted."); + + // check for not found + global $entry; + $this->set_current_entry($postID); + + if(!current_user_can('edit_post', $postID)) { + $this->auth_required(__('Sorry, you do not have the right to delete this post.')); + } + + $location = get_post_meta($entry['ID'], '_wp_attached_file', true); + + // delete file + @unlink($location); + + // delete attachment + $result = wp_delete_post($postID); + + if (!$result) { + $this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.')); + } + + log_app('function',"delete_attachment($postID). File '$location' deleted."); + $this->ok(); + } + + function get_file($postID) { + + // check for not found + global $entry; + $this->set_current_entry($postID); + + // then whether user can edit the specific post + if(!current_user_can('edit_post', $postID)) { + $this->auth_required(__('Sorry, you do not have the right to edit this post.')); + } + + $location = get_post_meta($entry['ID'], '_wp_attached_file', true); + + if(!isset($location)) + $this->internal_error(__('Error ocurred while accessing post metadata for file location.')); + + header('Content-Type: ' . $entry['post_mime_type']); + + $fp = fopen($location, "rb"); + while(!feof($fp)) { + echo fread($fp, 4096); + } + fclose($fp); + + log_app('function',"get_file($postID)"); + $this->ok(); + } + + function put_file($postID) { + + $type = $this->get_accepted_content_type(); + + // first check if user can upload + if(!current_user_can('upload_files')) + $this->auth_required(__('You do not have permission to upload files.')); + + // check for not found + global $entry; + $this->set_current_entry($postID); + + // then whether user can edit the specific post + if(!current_user_can('edit_post', $postID)) { + $this->auth_required(__('Sorry, you do not have the right to edit this post.')); + } + + $location = get_post_meta($entry['ID'], '_wp_attached_file', true); + + if(!isset($location)) + $this->internal_error(__('Error ocurred while accessing post metadata for file location.')); + + $fp = fopen("php://input", "rb"); + $localfp = fopen($location, "w+"); + while(!feof($fp)) { + fwrite($localfp,fread($fp, 4096)); + } + fclose($fp); + fclose($localfp); + + log_app('function',"put_file($postID)"); + $this->ok(); + } + + function get_entries_url($page = NULL) { + global $use_querystring; + $url = get_bloginfo('url') . '/' . $this->script_name; + if ($use_querystring) { + $url .= '?action=/' . $this->ENTRIES_PATH; + if(isset($page) && is_int($page)) { + $url .= "&eid=$page"; + } + } else { + $url .= '/' . $this->ENTRIES_PATH; + if(isset($page) && is_int($page)) { + $url .= "/$page"; + } + } + return $url; + } + + function the_entries_url($page = NULL) { + $url = $this->get_entries_url($page); + echo $url; + } + + function get_categories_url($page = NULL) { + global $use_querystring; + $url = get_bloginfo('url') . '/' . $this->script_name; + if ($use_querystring) { + $url .= '?action=/' . $this->CATEGORIES_PATH; + } else { + $url .= '/' . $this->CATEGORIES_PATH; + } + return $url; + } + + function the_categories_url() { + $url = $this->get_categories_url(); + echo $url; + } + + function get_attachments_url($page = NULL) { + global $use_querystring; + $url = get_bloginfo('url') . '/' . $this->script_name; + if ($use_querystring) { + $url .= '?action=/' . $this->MEDIA_PATH; + if(isset($page) && is_int($page)) { + $url .= "&eid=$page"; + } + } else { + $url .= '/' . $this->MEDIA_PATH; + if(isset($page) && is_int($page)) { + $url .= "/$page"; + } + } + return $url; + } + + function the_attachments_url($page = NULL) { + $url = $this->get_attachments_url($page); + echo $url; + } + + + function get_entry_url($postID = NULL) { + global $use_querystring; + if(!isset($postID)) { + global $post; + $postID = (int) $GLOBALS['post']->ID; + } + + if ($use_querystring) { + $url = get_bloginfo('url') . '/' . $this->script_name . '?action=/' . $this->ENTRY_PATH . "&eid=$postID"; + } else { + $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->ENTRY_PATH . "/$postID"; + } + + log_app('function',"get_entry_url() = $url"); + return $url; + } + + function the_entry_url($postID = NULL) { + $url = $this->get_entry_url($postID); + echo $url; + } + + function get_media_url($postID = NULL) { + global $use_querystring; + if(!isset($postID)) { + global $post; + $postID = (int) $GLOBALS['post']->ID; + } + + if ($use_querystring) { + $url = get_bloginfo('url') . '/' . $this->script_name . '?action=/' . $this->MEDIA_SINGLE_PATH ."&eid=$postID"; + } else { + $url = get_bloginfo('url') . '/' . $this->script_name . '/' . $this->MEDIA_SINGLE_PATH ."/$postID"; + } + + log_app('function',"get_media_url() = $url"); + return $url; + } + + function the_media_url($postID = NULL) { + $url = $this->get_media_url($postID); + echo $url; + } + + function set_current_entry($postID) { + global $entry; + log_app('function',"set_current_entry($postID)"); + + if(!isset($postID)) { + // $this->bad_request(); + $this->not_found(); + } + + $entry = wp_get_single_post($postID,ARRAY_A); + + if(!isset($entry) || !isset($entry['ID'])) + $this->not_found(); + + return; + } + + function get_posts_count() { + global $wpdb; + log_app('function',"get_posts_count()"); + return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_date_gmt < '" . gmdate("Y-m-d H:i:s",time()) . "'"); + } + + + function get_posts($page = 1, $post_type = 'post') { + log_app('function',"get_posts($page, '$post_type')"); + $feed = $this->get_feed($page, $post_type); + $this->output($feed); + } + + function get_attachments($page = 1, $post_type = 'attachment') { + log_app('function',"get_attachments($page, '$post_type')"); + $feed = $this->get_feed($page, $post_type); + $this->output($feed); + } + + function get_feed($page = 1, $post_type = 'post') { + global $post, $wp, $wp_query, $posts, $wpdb, $blog_id, $post_cache; + log_app('function',"get_feed($page, '$post_type')"); + ob_start(); + + if(!isset($page)) { + $page = 1; + } + $page = (int) $page; + + $count = get_option('posts_per_rss'); + $query = "paged=$page&posts_per_page=$count&order=DESC"; + if($post_type == 'attachment') { + $query .= "&post_type=$post_type"; + } + query_posts($query); + $post = $GLOBALS['post']; + $posts = $GLOBALS['posts']; + $wp = $GLOBALS['wp']; + $wp_query = $GLOBALS['wp_query']; + $wpdb = $GLOBALS['wpdb']; + $blog_id = (int) $GLOBALS['blog_id']; + $post_cache = $GLOBALS['post_cache']; + + + $total_count = $this->get_posts_count(); + $last_page = (int) ceil($total_count / $count); + $next_page = (($page + 1) > $last_page) ? NULL : $page + 1; + $prev_page = ($page - 1) < 1 ? NULL : $page - 1; + $last_page = ((int)$last_page == 1 || (int)$last_page == 0) ? NULL : (int) $last_page; +?> +the_entries_url() ?> + +<?php bloginfo_rss('name') ?> + + + + + + + + + + +Copyright +WordPress.com Atom API + + + ID); ?> + <![CDATA[<?php the_title() ?>]]> + + + + post_status == 'draft' ? 'yes' : 'no') ?> + + + + + + + + + post_status == 'attachment') { ?> + + + + + + + + + ]]> + post_content ) ) : ?> + ]]> + + + + + + + ID); ?> + <![CDATA[<?php the_title_rss() ?>]]> + + + + + post_status == 'draft' ? 'yes' : 'no') ?> + + + + + + +post_type == 'attachment') { ?> + + + + + + + + + + ]]> +post_content ) ) : ?> + ]]> + + +auth_required(__("Access Denied.")); + endif; + ob_end_clean(); + + log_app('get_entry returning:',$entry); + return $entry; + } + + function ok() { + log_app('Status','200: OK'); + header('Content-Type: text/plain'); + status_header('200'); + exit; + } + + function no_content() { + log_app('Status','204: No Content'); + header('Content-Type: text/plain'); + status_header('204'); + echo "Deleted."; + exit; + } + + function internal_error($msg = 'Internal Server Error') { + log_app('Status','500: Server Error'); + header('Content-Type: text/plain'); + status_header('500'); + echo $msg; + exit; + } + + function bad_request() { + log_app('Status','400: Bad Request'); + header('Content-Type: text/plain'); + status_header('400'); + exit; + } + + function length_required() { + log_app('Status','411: Length Required'); + header("HTTP/1.1 411 Length Required"); + header('Content-Type: text/plain'); + status_header('411'); + exit; + } + + function invalid_media() { + log_app('Status','415: Unsupported Media Type'); + header("HTTP/1.1 415 Unsupported Media Type"); + header('Content-Type: text/plain'); + exit; + } + + function not_found() { + log_app('Status','404: Not Found'); + header('Content-Type: text/plain'); + status_header('404'); + exit; + } + + function not_allowed($allow) { + log_app('Status','405: Not Allowed'); + header('Allow: ' . join(',', $allow)); + status_header('405'); + exit; + } + + function client_error($msg = 'Client Error') { + log_app('Status','400: Client Errir'); + header('Content-Type: text/plain'); + status_header('400'); + exit; + } + + function created($post_ID, $content, $post_type = 'post') { + global $use_querystring; + log_app('created()::$post_ID',"$post_ID, $post_type"); + $edit = $this->get_entry_url($post_ID); + switch($post_type) { + case 'post': + $ctloc = $this->get_entry_url($post_ID); + break; + case 'attachment': + if ($use_querystring) { + $edit = get_bloginfo('url') . '/' . $this->script_name . "?action=/attachments&eid=$post_ID"; + } else { + $edit = get_bloginfo('url') . '/' . $this->script_name . "/attachments/$post_ID"; + } + break; + } + header('Content-Type: application/atom+xml'); + if(isset($ctloc)) + header('Content-Location: ' . $ctloc); + header('Location: ' . $edit); + status_header('201'); + echo $content; + exit; + } + + function auth_required($msg) { + log_app('Status','401: Auth Required'); + nocache_headers(); + header('WWW-Authenticate: Basic realm="WordPress Atom Protocol"'); + header('WWW-Authenticate: Form action="' . get_option('siteurl') . '/wp-login.php"', false); + header("HTTP/1.1 401 $msg"); + header('Status: ' . $msg); + header('Content-Type: plain/text'); + echo $msg; + exit; + } + + function output($xml, $ctype = "application/atom+xml") { + status_header('200'); + $xml = ''."\n".$xml; + header('Connection: close'); + header('Content-Length: '. strlen($xml)); + header('Content-Type: ' . $ctype); + header('Content-Disposition: attachment; filename=atom.xml'); + header('Date: '. date('r')); + if($this->do_output) + echo $xml; + log_app('function', "output:\n$xml"); + exit; + } + + function escape(&$array) { + global $wpdb; + + foreach ($array as $k => $v) { + if (is_array($v)) { + $this->escape($array[$k]); + } else if (is_object($v)) { + //skip + } else { + $array[$k] = $wpdb->escape($v); + } + } + } + + + + /* + * Access credential through various methods and perform login + */ + function authenticate() { + $login_data = array(); + $already_md5 = false; + + log_app("authenticate()",print_r($_ENV, true)); + + // if using mod_rewrite/ENV hack + // http://www.besthostratings.com/articles/http-auth-php-cgi.html + if(isset($_SERVER['HTTP_AUTHORIZATION'])) { + list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = + explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); + } + + // If Basic Auth is working... + if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { + $login_data = array('login' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']); + } else { + // else, do cookie-based authentication + if (function_exists('wp_get_cookie_login')) { + $login_data = wp_get_cookie_login(); + $already_md5 = true; + } + } + + // call wp_login and set current user + if (!empty($login_data) && wp_login($login_data['login'], $login_data['password'], $already_md5)) { + $current_user = new WP_User(0, $login_data['login']); + wp_set_current_user($current_user->ID); + log_app("authenticate()",$login_data['login']); + } + } + + function get_accepted_content_type($types = NULL) { + + if(!isset($types)) { + $types = $this->media_content_types; + } + + if(!isset($_SERVER['CONTENT_LENGTH']) || !isset($_SERVER['CONTENT_TYPE'])) { + $this->length_required(); + } + + $type = $_SERVER['CONTENT_TYPE']; + list($type,$subtype) = explode('/',$type); + list($subtype) = explode(";",$subtype); // strip MIME parameters + log_app("get_accepted_content_type", "type=$type, subtype=$subtype"); + + foreach($types as $t) { + list($acceptedType,$acceptedSubtype) = explode('/',$t); + if($acceptedType == '*' || $acceptedType == $type) { + if($acceptedSubtype == '*' || $acceptedSubtype == $subtype) + return $type; + } + } + + $this->invalid_media(); + } + + + + function process_conditionals() { + + if(empty($this->params)) return; + if($_SERVER['REQUEST_METHOD'] == 'DELETE') return; + + switch($this->params[0]) { + case $this->ENTRY_PATH: + global $post; + $post = wp_get_single_post($this->params[1]); + $wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true); + $post = NULL; + break; + case $this->ENTRIES_PATH: + $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; + break; + default: + return; + } + $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'])) + $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); + else + $client_etag = false; + + $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']); + // If string is empty, return 0. If not, attempt to parse into a timestamp + $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; + + // Make a timestamp for our most recent modification... + $wp_modified_timestamp = strtotime($wp_last_modified); + + if ( ($client_last_modified && $client_etag) ? + (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : + (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { + status_header( 304 ); + exit; + } + } + + +} + +$server = new AtomServer(); +$server->handle_request(); + +?> diff --git a/wp-comments-post.php b/wp-comments-post.php index 5988fd5..9f5d3b8 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -1,4 +1,10 @@ + diff --git a/wp-content/index.php b/wp-content/index.php index 3d5acf0..4e6c07c 100644 --- a/wp-content/index.php +++ b/wp-content/index.php @@ -1,3 +1,3 @@ - \ No newline at end of file diff --git a/wp-content/themes/classic/functions.php b/wp-content/themes/classic/functions.php new file mode 100644 index 0000000..a63850c --- /dev/null +++ b/wp-content/themes/classic/functions.php @@ -0,0 +1,10 @@ + '
  • ', + 'after_widget' => '
  • ', + 'before_title' => '', + 'after_title' => '', + )); + +?> diff --git a/wp-content/themes/classic/index.php b/wp-content/themes/classic/index.php index 2760bff..ce02040 100644 --- a/wp-content/themes/classic/index.php +++ b/wp-content/themes/classic/index.php @@ -1,4 +1,4 @@ - @@ -15,8 +15,8 @@ get_header(); diff --git a/wp-content/themes/classic/sidebar.php b/wp-content/themes/classic/sidebar.php index ce72662..e4a680a 100644 --- a/wp-content/themes/classic/sidebar.php +++ b/wp-content/themes/classic/sidebar.php @@ -3,22 +3,14 @@ - - - - - + + diff --git a/wp-content/themes/classic/style.css b/wp-content/themes/classic/style.css index e09122d..f5436b2 100644 --- a/wp-content/themes/classic/style.css +++ b/wp-content/themes/classic/style.css @@ -48,9 +48,9 @@ blockquote { body { background: #fff; - border: solid 2px #565; - border-bottom: solid 1px #565; - border-top: solid 3px #565; + border: 2px solid #565; + border-bottom: 1px solid #565; + border-top: 3px solid #565; color: #000; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; margin: 0; @@ -71,7 +71,7 @@ h2 { } h3 { - border-bottom: dotted 1px #eee; + border-bottom: 1px dotted #eee; font-family: "Times New Roman", Times, serif; margin-top: 0; } @@ -96,7 +96,7 @@ ul.post-meta span.post-meta-key { .credit { background: #90a090; - border-top: double 3px #aba; + border-top: 3px double #aba; color: #fff; font-size: 11px; margin: 10px 0 0 0; @@ -166,10 +166,10 @@ ul.post-meta span.post-meta-key { #header { background: #90a090; - border-bottom: double 3px #aba; - border-left: solid 1px #9a9; - border-right: solid 1px #565; - border-top: solid 1px #9a9; + border-bottom: 3px double #aba; + border-left: 1px solid #9a9; + border-right: 1px solid #565; + border-top: 1px solid #9a9; font: italic normal 230% 'Times New Roman', Times, serif; letter-spacing: 0.2em; margin: 0; @@ -188,7 +188,7 @@ ul.post-meta span.post-meta-key { #menu { background: #fff; border-left: 1px dotted #ccc; - border-top: solid 3px #e0e6e0; + border-top: 3px solid #e0e6e0; padding: 20px 0 10px 30px; position: absolute; right: 2px; diff --git a/wp-content/themes/default/archive.php b/wp-content/themes/default/archive.php index 1d2b1de..db6db4c 100644 --- a/wp-content/themes/default/archive.php +++ b/wp-content/themes/default/archive.php @@ -4,26 +4,21 @@ - - + +

    Archive for the ‘’ Category

    Archive for

    - - +

    Archive for

    - - +

    Archive for

    -

    Author Archive

    - - +

    Blog Archives

    - - +
    '; html += '
    '; @@ -447,6 +555,7 @@ TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, div.setAttribute("width", width); div.setAttribute("height", (height)); div.style.position = "absolute"; + div.style.left = left + "px"; div.style.top = top + "px"; div.style.width = width + "px"; @@ -473,7 +582,7 @@ TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, iframe.setAttribute("topMargin", "0"); iframe.setAttribute("width", iframeWidth); iframe.setAttribute("height", iframeHeight); -// iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm"); + // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm"); // iframe.setAttribute("allowtransparency", "false"); iframe.setAttribute("scrolling", "no"); iframe.style.width = iframeWidth + "px"; @@ -522,7 +631,24 @@ TinyMCE_Window.prototype.minimize = function() { }; TinyMCE_Window.prototype.maximize = function() { - + if (this.restoreSize) { + this.moveTo(this.restoreSize[0], this.restoreSize[1]); + this.resizeTo(this.restoreSize[2], this.restoreSize[3]); + this.updateClamping(); + this.restoreSize = null; + } else { + var bounds = mcWindows.getBounds(); + this.restoreSize = [ + this.left, this.top, + this.winElement.scrollWidth, + this.winElement.scrollHeight + ]; + this.moveTo(bounds[0], bounds[1]); + this.resizeTo( + bounds[2] - bounds[0], + bounds[3] - bounds[1] + ); + } }; TinyMCE_Window.prototype.startResize = function() { @@ -552,7 +678,7 @@ TinyMCE_Window.prototype.close = function() { mcWindows.windows = mcWindowsNew; -// alert(mcWindows.doc.getElementById(this.id + "_iframe")); + // alert(mcWindows.doc.getElementById(this.id + "_iframe")); var e = mcWindows.doc.getElementById(this.id + "_iframe"); e.parentNode.removeChild(e); @@ -561,42 +687,24 @@ TinyMCE_Window.prototype.close = function() { e.parentNode.removeChild(e); mcWindows.setDocumentLock(false); - - tinyMCE.selectedInstance.getWin().focus(); // WordPress: focus on the editor after closing a popup }; TinyMCE_Window.prototype.onMouseMove = function(e) { - var scrollX = 0;//this.doc.body.scrollLeft; - var scrollY = 0;//this.doc.body.scrollTop; - + var clamp; // Calculate real X, Y var dx = e.screenX - mcWindows.mouseDownScreenX; var dy = e.screenY - mcWindows.mouseDownScreenY; switch (mcWindows.action) { case "resize": - width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX); - height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY); + clamp = mcWindows.clampBoxSize( + this.left, this.top, + mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX), + mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY), + this.features.minWidth, this.features.minHeight + ); - width = width < 100 ? 100 : width; - height = height < 100 ? 100 : height; - - this.wrapperIFrameElement.style.width = (width+2) + 'px'; - this.wrapperIFrameElement.style.height = (height+2) + 'px'; - this.wrapperIFrameElement.width = width+2; - this.wrapperIFrameElement.height = height+2; - this.winElement.style.width = width + 'px'; - this.winElement.style.height = height + 'px'; - - height = height - this.deltaHeight; - - this.containerElement.style.width = width + 'px'; - this.iframeElement.style.width = width + 'px'; - this.iframeElement.style.height = height + 'px'; - this.bodyElement.style.width = width + 'px'; - this.bodyElement.style.height = height + 'px'; - this.headElement.style.width = width + 'px'; - //this.statusElement.style.width = width + 'px'; + this.resizeTo(clamp[2], clamp[3]); mcWindows.cancelEvent(e); break; @@ -604,14 +712,59 @@ TinyMCE_Window.prototype.onMouseMove = function(e) { case "move": this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX); this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY); - this.winElement.style.left = this.left + "px"; - this.winElement.style.top = this.top + "px"; + this.updateClamping(); mcWindows.cancelEvent(e); break; } }; +TinyMCE_Window.prototype.moveTo = function (x, y) { + this.left = x; + this.top = y; + + this.winElement.style.left = this.left + "px"; + this.winElement.style.top = this.top + "px"; +}; + +TinyMCE_Window.prototype.resizeTo = function (width, height) { + this.wrapperIFrameElement.style.width = (width+2) + 'px'; + this.wrapperIFrameElement.style.height = (height+2) + 'px'; + this.wrapperIFrameElement.width = width+2; + this.wrapperIFrameElement.height = height+2; + this.winElement.style.width = width + 'px'; + this.winElement.style.height = height + 'px'; + + height = height - this.deltaHeight; + + this.containerElement.style.width = width + 'px'; + this.iframeElement.style.width = width + 'px'; + this.iframeElement.style.height = height + 'px'; + this.bodyElement.style.width = width + 'px'; + this.bodyElement.style.height = height + 'px'; + this.headElement.style.width = width + 'px'; + //this.statusElement.style.width = width + 'px'; +}; + +TinyMCE_Window.prototype.updateClamping = function () { + var clamp, oversize; + + clamp = mcWindows.clampBoxPosition( + this.left, this.top, + this.winElement.scrollWidth, + this.winElement.scrollHeight, + this.features.minWidth, this.features.minHeight + ); + oversize = ( + clamp[2] != this.winElement.scrollWidth || + clamp[3] != this.winElement.scrollHeight + ) ? true : false; + + this.moveTo(clamp[0], clamp[1]); + if (this.features.resizable == "yes" && oversize) + this.resizeTo(clamp[2], clamp[3]); +}; + function debug(msg) { document.getElementById('debug').value += msg + "\n"; } @@ -639,9 +792,6 @@ TinyMCE_Window.prototype.onFocus = function(e) { TinyMCE_Window.prototype.onMouseDown = function(e) { var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target; - var scrollX = 0;//this.doc.body.scrollLeft; - var scrollY = 0;//this.doc.body.scrollTop; - mcWindows.mouseDownScreenX = e.screenX; mcWindows.mouseDownScreenY = e.screenY; mcWindows.mouseDownLayerX = this.left; diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js index 3ef1d7a..5e884cf 100644 --- a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js @@ -1,5 +1,5 @@ /** - * $Id: editor_plugin_src.js 162 2007-01-03 16:16:52Z spocke $ + * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. @@ -14,7 +14,7 @@ var TinyMCE_PastePlugin = { longname : 'Paste text/word', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html', + infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, @@ -24,6 +24,16 @@ var TinyMCE_PastePlugin = { tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent); }, + handleEvent : function(e) { + // Force paste dialog if non IE browser + if (!tinyMCE.isRealIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false) && e.ctrlKey && e.keyCode == 86 && e.type == "keydown") { + window.setTimeout('tinyMCE.selectedInstance.execCommand("mcePasteText",true)', 1); + return tinyMCE.cancelEvent(e); + } + + return true; + }, + getControlHTML : function(cn) { switch (cn) { case "pastetext": diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php index cf3d800..0127ff1 100755 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php @@ -78,19 +78,8 @@ class TinyGoogleSpell { $header .= $xml; //$this->_debugData($xml); - // Use raw sockets - $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30); - if ($fp) { - // Send request - fwrite($fp, $header); - - // Read response - $xml = ""; - while (!feof($fp)) - $xml .= fgets($fp, 128); - - fclose($fp); - } else { + // Use curl if it exists + if (function_exists('curl_init')) { // Use curl $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); @@ -99,6 +88,21 @@ class TinyGoogleSpell { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $xml = curl_exec($ch); curl_close($ch); + } else { + // Use raw sockets + $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30); + if ($fp) { + // Send request + fwrite($fp, $header); + + // Read response + $xml = ""; + while (!feof($fp)) + $xml .= fgets($fp, 128); + + fclose($fp); + } else + echo "Could not open SSL connection to google."; } //$this->_debugData($xml); diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index ede6576..f834e97 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -515,7 +515,7 @@ function switchEditors(id) { ta.style.height = (ta.clientHeight + y1 - y2) + 'px'; // Tweak the widths - ta.parentNode.style.paddingRight = '2px'; + ta.parentNode.style.paddingRight = '12px'; if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) { } else { diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js index 2d4e1e3..68ca7ba 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js +++ b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js @@ -4,6 +4,10 @@ if (navigator.userAgent.indexOf('Mac OS') != -1) { // Mac OS browsers use Ctrl to hit accesskeys var metaKey = 'Ctrl'; } +else if (navigator.userAgent.indexOf('Firefox/2') != -1) { +// Firefox 2.x uses Alt+Shift to hit accesskeys + var metaKey = 'Alt+Shift'; +} else { var metaKey = 'Alt'; } diff --git a/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm index e5fdc9f..5e24920 100644 --- a/wp-includes/js/tinymce/themes/advanced/color_picker.htm +++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm @@ -2,12 +2,73 @@ {$lang_theme_colorpicker_title} + + - -
    - + + + +
    +
    +
    + {$lang_color_picker} +
    + + +
    + +
    + +
    +
    +
    +
    + +
    +
    + {$lang_web_colors} +
    + +
    + +
    +
    +
    + +
    +
    + {$lang_named_colors} +
    + +
    + +
    + +
    + {$lang_color_name} +
    +
    +
    +
    + +
    +
    + +
    + +
    + +
    + +
    diff --git a/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css b/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css new file mode 100644 index 0000000..4b0360b --- /dev/null +++ b/wp-includes/js/tinymce/themes/advanced/css/colorpicker.css @@ -0,0 +1,53 @@ +/* Colorpicker dialog specific CSS */ + +#preview { + float: right; + width: 50px; + height: 14px; + line-height: 1px; + border: 1px solid black; + margin-left: 5px; +} + +#colorpicker { + float: left; + cursor: crosshair; +} + +#light { + border: 1px solid gray; + margin-left: 5px; + float: left; + width: 15px; + cursor: crosshair; +} + +#light div { + overflow: hidden; +} + +#previewblock { + float: right; + padding-left: 10px; + height: 20px; +} + +.panel_wrapper div.current { + height: 175px; +} + +#namedcolors { + width: 150px; +} + +#namedcolors a { + display: block; + float: left; + width: 10px; height: 10px; + margin: 1px 1px 0 0; + overflow: hidden; +} + +#colornamecontainer { + margin-top: 5px; +} \ No newline at end of file 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 58e6b8e..851837d 100644 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css @@ -11,7 +11,7 @@ .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;} +.mceToolbarContainer {display: block; position: relative; left: 0; top: 0; width: 100%;} .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;} @@ -49,7 +49,7 @@ span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A /* Menu */ -.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 100; background-color: white; border: 1px solid gray; font-weight: normal;} +.mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 1000; 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;} @@ -61,7 +61,7 @@ span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif'); bac 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;} +a.mceMoreColors {width: auto; padding: 0; margin: 0 3px 3px 3px; text-align: center; border: 1px solid white; text-decoration: none !important;} .mceColorPreview {position: absolute; overflow:hidden; 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;} @@ -77,7 +77,7 @@ a.mceMoreColors:hover {border: 1px solid #0A246A;} * 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 a.mceMoreColors {width: auto;} * html .mceColors td a {width: 10px; height: 10px;} * html .mceColorPreview {margin-left: 2px; margin-top: 14px;} @@ -92,6 +92,6 @@ a.mceMoreColors:hover {border: 1px solid #0A246A;} *: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 a.mceMoreColors {width: 137px;} *: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 3d91891..b8e3685 100644 --- a/wp-includes/js/tinymce/themes/advanced/editor_template.js +++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js @@ -1,5 +1,5 @@ /** - * $Id: editor_template_src.js 166 2007-01-05 10:31:50Z spocke $ + * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. @@ -43,7 +43,9 @@ var TinyMCE_AdvancedTheme = { ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'], ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'], ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true], + ['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true], ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true], + ['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', 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'], @@ -356,6 +358,10 @@ var TinyMCE_AdvancedTheme = { return false; + case "forecolorpicker": + this._pickColor(editor_id, 'forecolor'); + return true; + case "forecolorMenu": TinyMCE_AdvancedTheme._hideMenus(editor_id); @@ -420,15 +426,21 @@ var TinyMCE_AdvancedTheme = { ml.show(); return true; + + case "backcolorpicker": + this._pickColor(editor_id, 'HiliteColor'); + return true; case "mceColorPicker": if (user_interface) { - var template = new Array(); - var inputColor = value['document'].getElementById(value['element_id']).value; + var template = []; + + if (!value['callback'] && !value['color']) + value['color'] = value['document'].getElementById(value['element_id']).value; template['file'] = 'color_picker.htm'; - template['width'] = 220; - template['height'] = 190; + template['width'] = 380; + template['height'] = 250; template['close_previous'] = "no"; template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); @@ -438,10 +450,16 @@ var TinyMCE_AdvancedTheme = { value['store_selection'] = true; tinyMCE.lastColorPickerValue = value; - tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor}); + tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']}); } else { - var savedVal = tinyMCE.lastColorPickerValue; - var elm = savedVal['document'].getElementById(savedVal['element_id']); + var savedVal = tinyMCE.lastColorPickerValue, elm; + + if (savedVal['callback']) { + savedVal['callback'](value); + return true; + } + + elm = savedVal['document'].getElementById(savedVal['element_id']); elm.value = value; if (elm.onchange != null && elm.onchange != '') @@ -599,9 +617,8 @@ var TinyMCE_AdvancedTheme = { // Setup template html template['html'] = ''; - if (toolbarLocation == "top") { - template['html'] += ''; - } + if (toolbarLocation == "top") + template['html'] += ''; if (statusbarLocation == "top") { template['html'] += ''; @@ -610,9 +627,8 @@ var TinyMCE_AdvancedTheme = { template['html'] += ''; - if (toolbarLocation == "bottom") { - template['html'] += ''; - } + if (toolbarLocation == "bottom") + template['html'] += ''; // External toolbar changes if (toolbarLocation == "external") { @@ -738,9 +754,12 @@ var TinyMCE_AdvancedTheme = { }, removeInstance : function(inst) { - var fcm = new TinyMCE_Layer(inst.editorId + '_fcMenu'); + new TinyMCE_Layer(inst.editorId + '_fcMenu').remove(); + new TinyMCE_Layer(inst.editorId + '_bcMenu').remove(); + }, - fcm.remove(); + hideInstance : function(inst) { + TinyMCE_AdvancedTheme._hideMenus(inst.editorId); }, _handleMenuEvent : function(e) { @@ -1224,6 +1243,7 @@ var TinyMCE_AdvancedTheme = { if (set_w) tableElm.style.width = w + "px"; + if ( !tinyMCE.isMSIE || tinyMCE.isMSIE7 || tinyMCE.isOpera ) // WordPress: do this later to avoid creeping toolbar bug in MSIE6 tableElm.style.height = h + "px"; iw = iframe.clientWidth + dx; @@ -1232,10 +1252,12 @@ var TinyMCE_AdvancedTheme = { iw = iw < 1 ? 30 : iw; ih = ih < 1 ? 30 : ih; +/* WordPress found that this led to a shrinking editor with every resize. (Gray background creeps in 1px at a time.) if (tinyMCE.isGecko) { iw -= 2; ih -= 2; } +*/ if (set_w) iframe.style.width = iw + "px"; @@ -1253,6 +1275,8 @@ var TinyMCE_AdvancedTheme = { } } + tableElm.style.height = h + "px"; // WordPress: see above + // Remove pesky table controls inst.useCSS = false; }, @@ -1378,13 +1402,27 @@ var TinyMCE_AdvancedTheme = { } h += '
    ' + toolbarHTML + '
    ' + toolbarHTML + '
    ' + statusbarHTML + '
    ' + toolbarHTML + '
    ' + toolbarHTML + '
    '; - /* - h += 'More colors'; - */ + + if (tinyMCE.getParam("theme_advanced_more_colors", true)) + h += '' + tinyMCE.getLang('lang_more_colors') + ''; return h; }, + _pickColor : function(id, cm) { + var inputColor, inst = tinyMCE.selectedInstance; + + if (cm == 'forecolor' && inst) + inputColor = inst.foreColor; + + if ((cm == 'backcolor' || cm == 'HiliteColor') && inst) + inputColor = inst.backColor; + + tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) { + tinyMCE.execInstanceCommand(id, cm, false, c); + }}); + }, + _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/images/colors.jpg b/wp-includes/js/tinymce/themes/advanced/images/colors.jpg new file mode 100644 index 0000000..b4c542d Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/colors.jpg differ diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js index aa80714..78425e4 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js @@ -1,19 +1,4 @@ -function init() { - if (tinyMCE.isMSIE) - tinyMCEPopup.resizeToInnerSize(); -} - -function selectColor() { - var color = document.getElementById("selectedColorBox").value; - - tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color); - tinyMCEPopup.close(); -} - -function showColor(color) { - document.getElementById("selectedColor").style.backgroundColor = color; - document.getElementById("selectedColorBox").value = color; -} +var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false; var colors = new Array( "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033", @@ -45,9 +30,71 @@ var colors = new Array( "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff" ); +var named = { + '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige', + '#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown', + '#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue', + '#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod', + '#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen', + '#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue', + '#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue', + '#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen', + '#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey', + '#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory', + '#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue', + '#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen', + '#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey', + '#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon', + '#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue', + '#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin', + '#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid', + '#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff', + '#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue', + '#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver', + '#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen', + '#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet', + '#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen' +}; + +function init() { + var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color')); + + if (tinyMCE.isMSIE) + tinyMCEPopup.resizeToInnerSize(); + + generatePicker(); + + if (inputColor) { + changeFinalColor(inputColor); + + col = convertHexToRGB(inputColor); + + if (col) + updateLight(col.r, col.g, col.b); + } +} + +function insertAction() { + var color = document.getElementById("color").value; + + tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color); + tinyMCEPopup.close(); +} + +function showColor(color, name) { + if (name) + document.getElementById("colorname").innerHTML = name; + + document.getElementById("preview").style.backgroundColor = color; + document.getElementById("color").value = color; +} + function convertRGBToHex(col) { var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi"); + if (!col) + return col; + var rgb = col.replace(re, "$1,$2,$3").split(','); if (rgb.length == 3) { r = parseInt(rgb[0]).toString(16); @@ -72,37 +119,131 @@ function convertHexToRGB(col) { g = parseInt(col.substring(2, 4), 16); b = parseInt(col.substring(4, 6), 16); - return "rgb(" + r + "," + g + "," + b + ")"; + return {r : r, g : g, b : b}; } - return col; + return null; } -function renderColorMap() { - var html = ""; - var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color')); +function generatePicker() { + var el = document.getElementById('light'), h = '', i; + + for (i = 0; i < detail; i++){ + h += '
    '; + } + + el.innerHTML = h; +} + +function generateWebColors() { + var el = document.getElementById('webcolors'), h = '', i; + + if (el.className == 'generated') + return; - html += '' + h += '
    ' + ''; - for (var i=0; i' + + for (i=0; i' + '' + '' + colors[i] +  ''; if ((i+1) % 18 == 0) - html += ''; + h += ''; + } + + h += '
    '; + + el.innerHTML = h; + el.className = 'generated'; +} + +function generateNamedColors() { + var el = document.getElementById('namedcolors'), h = '', n, v, i = 0; + + if (el.className == 'generated') + return; + + for (n in named) { + v = named[n]; + h += '' + } + + el.innerHTML = h; + el.className = 'generated'; +} + +function selectColor() { + var color = document.getElementById("color").value; + + if(window.opener) + window.opener.tinyMCE.execInstanceCommand(tinyMCE.getWindowArg('editor_id'),tinyMCE.getWindowArg('command'),false,color); + + window.close(); +} + +function dechex(n) { + return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16); +} + +function computeColor(e) { + var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB; + + x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0); + y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0); + + partWidth = document.getElementById('colorpicker').width / 6; + partDetail = detail / 2; + imHeight = document.getElementById('colorpicker').height; + + r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255; + g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255 + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth); + b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth); + + coef = (imHeight - y) / imHeight; + r = 128 + (r - 128) * coef; + g = 128 + (g - 128) * coef; + b = 128 + (b - 128) * coef; + + changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b)); + updateLight(r, g, b); +} + +function updateLight(r, g, b) { + var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color; + + for (i=0; i=0) && (i' - + '' - + '' - + '' - + '' - + '' - + '' - + '
    ' - + '
    ' - + '' - + ''; - - document.write(html); -} \ No newline at end of file +} + +function changeFinalColor(color) { + if (color.indexOf('#') == -1) + color = convertRGBToHex(color); + + document.getElementById('preview').style.backgroundColor = color; + document.getElementById('color').value = color; +} + +window.focus(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js index 990b7a4..9adac22 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js @@ -27,6 +27,7 @@ function init() { document.forms[0].href.value = tinyMCE.getWindowArg('href') || 'http://'; document.forms[0].href.select(); + document.forms[0].href.focus(); document.forms[0].linktitle.value = tinyMCE.getWindowArg('title'); document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); @@ -57,8 +58,8 @@ function insertLink() { var title = document.forms[0].linktitle.value; var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : ""; var dummy; - - // Make anchors absolute + + // WordPress: Make anchors absolute; if (href.charAt(0) == '#') href = tinyMCE.settings['document_base_url'] + href; diff --git a/wp-includes/js/tinymce/themes/advanced/langs/en.js b/wp-includes/js/tinymce/themes/advanced/langs/en.js index fd915ea..c658d6d 100644 --- a/wp-includes/js/tinymce/themes/advanced/langs/en.js +++ b/wp-includes/js/tinymce/themes/advanced/langs/en.js @@ -78,5 +78,14 @@ 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', -invalid_data : 'Error: Invalid values entered, these are marked in red.' +invalid_data : 'Error: Invalid values entered, these are marked in red.', +more_colors : 'More colors', +color_picker_tab : 'Picker', +color_picker : 'Color picker', +web_colors_tab : 'Web safe', +web_colors : 'Web safe colors', +named_colors_tab : 'Named', +named_colors : 'Named colors', +color : 'Color:', +color_name : 'Name:' }); diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js index c3f2159..e425a1e 100644 --- a/wp-includes/js/tinymce/tiny_mce.js +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -5,8 +5,8 @@ function TinyMCE_Engine() { var ua; this.majorVersion = "2"; - this.minorVersion = "0.9"; - this.releaseDate = "2007-01-09"; + this.minorVersion = "1.0"; + this.releaseDate = "2007-02-13"; this.instances = new Array(); this.switchClassCache = new Array(); @@ -186,7 +186,7 @@ TinyMCE_Engine.prototype = { this._def("custom_shortcuts", true); this._def("convert_on_click", false); this._def("content_css", ''); - this._def("fix_list_elements", false); + this._def("fix_list_elements", true); this._def("fix_table_elements", false); this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml'); this._def("hidden_tab_class", ''); @@ -241,7 +241,7 @@ TinyMCE_Engine.prototype = { 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.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL this.uniqueTag = ''; this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance'); @@ -740,6 +740,35 @@ TinyMCE_Engine.prototype = { tinyMCE.removeMCEControl(value); return; + case "mceToggleEditor": + var inst = tinyMCE.getInstanceById(value), pe, te; + + if (inst) { + pe = document.getElementById(inst.editorId + '_parent'); + te = inst.oldTargetElement; + + if (typeof(inst.enabled) == 'undefined') + inst.enabled = true; + + inst.enabled = !inst.enabled; + + if (!inst.enabled) { + pe.style.display = 'none'; + te.value = inst.getHTML(); + te.style.display = inst.oldTargetDisplay; + tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst); + } else { + pe.style.display = 'block'; + te.style.display = 'none'; + inst.setHTML(te.value); + inst.useCSS = false; + tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst); + } + } else + tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); + + return; + case "mceResetDesignMode": // Resets the designmode state of the editors in Gecko if (!tinyMCE.isIE) { @@ -961,10 +990,6 @@ TinyMCE_Engine.prototype = { // Fix for bug #957681 //inst.getDoc().designMode = inst.getDoc().designMode; - // Setup element references - var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent'); - inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; - tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst); tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc()); @@ -1445,9 +1470,9 @@ TinyMCE_Engine.prototype = { h += ''; } else { if (tinyMCE.isRealIE) - h += ''; + h += ''; else - h += ''; + h += ''; h += ''; h += ''; @@ -1693,7 +1718,7 @@ TinyMCE_Engine.prototype = { }, triggerNodeChange : function(focus, setup_content) { - var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false; + var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st; if (tinyMCE.selectedInstance) { inst = tinyMCE.selectedInstance; @@ -1705,7 +1730,7 @@ TinyMCE_Engine.prototype = { inst.lastTriggerEl = elm;*/ editorId = inst.editorId; - selectedText = inst.selection.getSelectedText(); + st = inst.selection.getSelectedText(); if (tinyMCE.settings.auto_resize) inst.resizeToContent(); @@ -1716,7 +1741,7 @@ TinyMCE_Engine.prototype = { inst.switchSettings(); if (tinyMCE.selectedElement) - anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0); + anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0); if (tinyMCE.settings['custom_undo_redo']) { undoIndex = inst.undoRedo.undoIndex; @@ -2180,11 +2205,11 @@ TinyMCE_Engine.prototype = { }, getCSSClasses : function(editor_id, doc) { - var output = new Array(); + var inst = tinyMCE.getInstanceById(editor_id); // Is cached, use that - if (typeof(tinyMCE.cssClasses) != "undefined") - return tinyMCE.cssClasses; + if (inst && inst.cssClasses.length > 0) + return inst.cssClasses; if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") { var instance; @@ -2242,13 +2267,13 @@ TinyMCE_Engine.prototype = { var cssClass = rule.substring(rule.indexOf('.') + 1); var addClass = true; - for (var p=0; p 0) - tinyMCE.cssClasses = output; - - return output; + return inst.cssClasses; }, regexpReplace : function(in_str, reg_exp, replace_str, opts) { @@ -2289,19 +2310,27 @@ TinyMCE_Engine.prototype = { }, getControlHTML : function(c) { - var i, l, n, o, v; + var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl'; l = tinyMCE.plugins; for (n in l) { o = l[n]; - if (o.getControlHTML && (v = o.getControlHTML(c)) != '') + if (o.getControlHTML && (v = o.getControlHTML(c)) != '') { + if (rtl) + return '' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + ''; + return tinyMCE.replaceVar(v, "pluginurl", o.baseURL); + } } o = tinyMCE.themes[tinyMCE.settings['theme']]; - if (o.getControlHTML && (v = o.getControlHTML(c)) != '') + if (o.getControlHTML && (v = o.getControlHTML(c)) != '') { + if (rtl) + return '' + v + ''; + return v; + } return ''; }, @@ -2433,6 +2462,7 @@ function TinyMCE_Control(settings) { this.hasMouseMoved = false; this.foreColor = this.backColor = "#999999"; this.data = {}; + this.cssClasses = []; this.cleanup.init({ valid_elements : s.valid_elements, @@ -2865,7 +2895,7 @@ TinyMCE_Control.prototype = { if (tinyMCE.isGecko && this.getSel().isCollapsed) { focusElm = tinyMCE.getParentElement(focusElm, 'A'); - if (focusElm && this.getRng(0).endOffset > 0 && this.getRng(0).endOffset != focusElm.innerHTML.length) // WordPress mod to prevent unlinking if caret at start/end of link + if (focusElm) this.selection.selectNode(focusElm, false); } @@ -3690,6 +3720,7 @@ TinyMCE_Control.prototype = { hc = ''; } else { hc = ''; + this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); this.oldTargetElement.style.display = "none"; } @@ -3715,8 +3746,10 @@ TinyMCE_Control.prototype = { // Just hide the textarea element this.oldTargetElement = replace_element; - if (!tinyMCE.settings['debug']) + if (!tinyMCE.settings['debug']) { + this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); this.oldTargetElement.style.display = "none"; + } // Output HTML and set editable if (tinyMCE.isGecko) { @@ -3790,6 +3823,10 @@ TinyMCE_Control.prototype = { if (tinyMCE.isIE) window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1); + // Setup element references + var parentElm = this.targetDoc.getElementById(this.editorId + '_parent'); + this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; + tinyMCE.setupContent(this.editorId, true); return true; @@ -4865,7 +4902,7 @@ TinyMCE_Cleanup.prototype = { if (r.forceAttribs && (t = r.forceAttribs[an])) av = t; - if (os && av.length != 0 && this.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an)) + if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an)) av = this._urlConverter(this, n, av); if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av)) @@ -5186,9 +5223,10 @@ TinyMCE_Engine.prototype.setInnerHTML = function(e, h) { // Convert all strong/em to b/i in Gecko if (tinyMCE.isGecko) { - h = h.replace(/]*)>/gi, ''); + h = h.replace(/]*)>/gi, ''); + h = h.replace(/]*)>/gi, ''); + h = h.replace(/]*)>/gi, ''); h = h.replace(/<\/strong>/gi, ''); h = h.replace(/<\/em>/gi, ''); } @@ -5503,6 +5541,32 @@ TinyMCE_Engine.prototype.getViewPort = function(w) { }; }; +TinyMCE_Engine.prototype.getStyle = function(n, na, d) { + if (!n) + return false; + + // Gecko + if (tinyMCE.isGecko && n.ownerDocument.defaultView) { + try { + return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na); + } catch (n) { + // Old safari might fail + return null; + } + } + + // Camelcase it, if needed + na = na.replace(/-(\D)/g, function(a, b){ + return b.toUpperCase(); + }); + + // IE & Opera + if (n.currentStyle) + return n.currentStyle[na]; + + return false; +}; + /* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */ TinyMCE_Engine.prototype.parseURL = function(url_str) { @@ -7132,13 +7196,21 @@ TinyMCE_Layer.prototype = { }, show : function() { - this.getElement().style.display = 'block'; - this.updateBlocker(); + var el = this.getElement(); + + if (el) { + el.style.display = 'block'; + this.updateBlocker(); + } }, hide : function() { - this.getElement().style.display = 'none'; - this.updateBlocker(); + var el = this.getElement(); + + if (el) { + el.style.display = 'none'; + this.updateBlocker(); + } }, isVisible : function() { diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php index 9e06575..de01c67 100644 --- a/wp-includes/js/tinymce/tiny_mce_config.php +++ b/wp-includes/js/tinymce/tiny_mce_config.php @@ -29,7 +29,7 @@ $plugins = apply_filters('mce_plugins', $plugins); $plugins = implode($plugins, ','); - $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'link', 'unlink', 'image', 'wp_more', 'separator', 'spellchecker', 'separator', 'wp_help', 'wp_adv_start', 'wp_adv', 'separator', 'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'wp_adv_end')); + $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright', 'separator', 'link', 'unlink', 'image', 'wp_more', 'separator', 'spellchecker', 'separator', 'wp_help', 'wp_adv', 'wp_adv_start', 'formatselect', 'underline', 'justifyfull', 'forecolor', 'separator', 'pastetext', 'pasteword', 'separator', 'removeformat', 'cleanup', 'separator', 'charmap', 'separator', 'undo', 'redo', 'wp_adv_end')); $mce_buttons = implode($mce_buttons, ','); $mce_buttons_2 = apply_filters('mce_buttons_2', array()); @@ -48,6 +48,8 @@ $mce_css = str_replace('http://', 'https://', $mce_css); $mce_popups_css = str_replace('http://', 'https://', $mce_popups_css); } + + $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower(get_locale()); ?> initArray = { @@ -58,7 +60,7 @@ initArray = { theme_advanced_buttons1 : "", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", - language : "", + language : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_path_location : "bottom", @@ -76,6 +78,7 @@ initArray = { fix_list_elements : true, gecko_spellcheck : true, entities : "38,amp,60,lt,62,gt", + button_tile_map : true, content_css : "", valid_elements : "", save_callback : 'TinyMCE_wordpressPlugin.saveCallback', diff --git a/wp-includes/js/tinymce/tiny_mce_gzip.php b/wp-includes/js/tinymce/tiny_mce_gzip.php index 59af4b6..14ffba3 100644 --- a/wp-includes/js/tinymce/tiny_mce_gzip.php +++ b/wp-includes/js/tinymce/tiny_mce_gzip.php @@ -84,7 +84,7 @@ if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']))); - if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) { + if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') { $enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip"; $supportsGzip = true; } diff --git a/wp-includes/js/wp-ajax.js b/wp-includes/js/wp-ajax.js index cc3bb5a..e3f63f7 100644 --- a/wp-includes/js/wp-ajax.js +++ b/wp-includes/js/wp-ajax.js @@ -27,9 +27,9 @@ Object.extend(WPAjax.prototype, { this.getResponseElement(responseEl); }, addArg: function(key, value) { - var a = []; + var a = $H(); a[encodeURIComponent(key)] = encodeURIComponent(value); - this.options.parameters = $H(this.options.parameters).merge($H(a)); + this.options.parameters = $H(this.options.parameters).merge(a); }, getResponseElement: function(r) { var p = $(r + '-p'); diff --git a/wp-includes/kses.php b/wp-includes/kses.php index aa9e465..4b5a284 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -18,253 +18,207 @@ if (!defined('CUSTOM_TAGS')) // You can override this in your my-hacks.php file if (!CUSTOM_TAGS) { - $allowedposttags = array ( - 'address' => array (), - 'a' => array ( - 'class' => array (), - 'href' => array (), - 'id' => array (), - 'title' => array (), - 'rel' => array (), - 'rev' => array (), - 'name' => array (), - 'target' => array()), - 'abbr' => array ( - 'title' => array ()), - 'acronym' => array ( - 'title' => array ()), - 'b' => array (), - 'big' => array (), - 'blockquote' => array ( - 'id' => array (), - 'cite' => array ()), - 'br' => array ( - 'class' => array ()), - 'button' => array ( - 'disabled' => array (), - 'name' => array (), - 'type' => array (), - 'value' => array ()), - 'caption' => array ( - 'align' => array (), - 'class' => array ()), - 'cite' => array ( - 'class' => array(), - 'dir' => array(), - 'lang' => array(), - 'title' => array ()), - 'code' => array (), - 'col' => array ( - 'align' => array (), - 'char' => array (), - 'charoff' => array (), - 'span' => array (), - 'dir' => array(), - 'valign' => array (), - 'width' => array ()), - 'del' => array ( - 'datetime' => array ()), - 'dd' => array (), - 'div' => array ( - 'align' => array (), - 'class' => array (), - 'dir' => array ()), - 'dl' => array (), - 'dt' => array (), - 'em' => array (), - 'fieldset' => array (), - 'font' => array ( - 'color' => array (), - 'face' => array (), - 'size' => array ()), - 'form' => array ( - 'action' => array (), - 'accept' => array (), - 'accept-charset' => array (), - 'enctype' => array (), - 'method' => array (), - 'name' => array (), - 'target' => array ()), - 'h1' => array ( - 'align' => array (), - 'class' => array ()), - 'h2' => array ( - 'align' => array (), - 'class' => array ()), - 'h3' => array ( - 'align' => array (), - 'class' => array ()), - 'h4' => array ( - 'align' => array (), - 'class' => array ()), - 'h5' => array ( - 'align' => array (), - 'class' => array ()), - 'h6' => array ( - 'align' => array (), - 'class' => array ()), - 'hr' => array ( - 'align' => array (), - 'class' => array (), - 'noshade' => array (), - 'size' => array (), - 'width' => array ()), - 'i' => array (), - 'img' => array ( - 'alt' => array (), - 'align' => array (), - 'border' => array (), - 'class' => array (), - 'height' => array (), - 'hspace' => array (), - 'longdesc' => array (), - 'vspace' => array (), - 'src' => array (), - 'width' => array ()), - 'ins' => array ( - 'datetime' => array (), - 'cite' => array ()), - 'kbd' => array (), - 'label' => array ( - 'for' => array ()), - 'legend' => array ( - 'align' => array ()), - 'li' => array ( - 'align' => array (), - 'class' => array ()), - 'p' => array ( - 'class' => array (), - 'align' => array (), - 'dir' => array()), - 'pre' => array ( - 'width' => array ()), - 'q' => array ( - 'cite' => array ()), - 's' => array (), - 'span' => array ( - 'class' => array (), - 'dir' => array (), - 'align' => array ()), - 'strike' => array (), - 'strong' => array (), - 'sub' => array (), - 'sup' => array (), - 'table' => array ( - 'align' => array (), - 'bgcolor' => array (), - 'border' => array (), - 'cellpadding' => array (), - 'cellspacing' => array (), - 'class' => array (), - 'dir' => array(), - 'rules' => array (), - 'summary' => array (), - 'width' => array ()), - 'tbody' => array ( - 'align' => array (), - 'char' => array (), - 'charoff' => array (), - 'valign' => array ()), - 'td' => array ( - 'abbr' => array (), - 'align' => array (), - 'axis' => array (), - 'bgcolor' => array (), - 'char' => array (), - 'charoff' => array (), - 'class' => array (), - 'colspan' => array (), - 'dir' => array(), - 'headers' => array (), - 'height' => array (), - 'nowrap' => array (), - 'rowspan' => array (), - 'scope' => array (), - 'valign' => array (), - 'width' => array ()), - 'textarea' => array ( - 'cols' => array (), - 'rows' => array (), - 'disabled' => array (), - 'name' => array (), - 'readonly' => array ()), - 'tfoot' => array ( - 'align' => array (), - 'char' => array (), - 'class' => array (), - 'charoff' => array (), - 'valign' => array ()), - 'th' => array ( - 'abbr' => array (), - 'align' => array (), - 'axis' => array (), - 'bgcolor' => array (), - 'char' => array (), - 'charoff' => array (), - 'class' => array (), - 'colspan' => array (), - 'headers' => array (), - 'height' => array (), - 'nowrap' => array (), - 'rowspan' => array (), - 'scope' => array (), - 'valign' => array (), - 'width' => array ()), - 'thead' => array ( - 'align' => array (), - 'char' => array (), - 'charoff' => array (), - 'class' => array (), - 'valign' => array ()), - 'title' => array (), - 'tr' => array ( - 'align' => array (), - 'bgcolor' => array (), - 'char' => array (), - 'charoff' => array (), - 'class' => array (), - 'valign' => array ()), - 'tt' => array (), - 'u' => array (), - 'ul' => array ( - 'class' => array ()), - 'ol' => array ( - 'class' => array ()), - 'var' => array ()); - $allowedtags = array ( - 'a' => array ( - 'href' => array (), - 'title' => array ()), - 'abbr' => array ( - 'title' => array ()), - 'acronym' => array ( - 'title' => array ()), - 'b' => array (), - 'blockquote' => array ( - 'cite' => array ()), - // 'br' => array(), - 'cite' => array (), - 'code' => array (), + $allowedposttags = array( + 'address' => array(), + 'a' => array( + 'href' => array(), 'title' => array(), + 'rel' => array(), 'rev' => array(), + 'name' => array() + ), + 'abbr' => array( + 'title' => array(), 'class' => array() + ), + 'acronym' => array( + 'title' => array() + ), + 'b' => array(), + 'big' => array(), + 'blockquote' => array( + 'cite' => array(), 'xml:lang' => array(), + 'lang' => array() + ), + 'br' => array(), + 'button' => array( + 'disabled' => array(), 'name' => array(), + 'type' => array(), 'value' => array() + ), + 'caption' => array( + 'align' => array() + ), + 'code' => array(), + 'col' => array( + 'align' => array(), 'char' => array(), + 'charoff' => array(), 'span' => array(), + 'valign' => array(), 'width' => array() + ), 'del' => array( - 'datetime' => array ()), - // 'dd' => array(), - // 'dl' => array(), - // 'dt' => array(), - 'em' => array (), 'i' => array (), - // 'ins' => array('datetime' => array(), 'cite' => array()), - // 'li' => array(), - // 'ol' => array(), - // 'p' => array(), + 'datetime' => array() + ), + 'dd' => array(), + 'div' => array( + 'align' => array(), 'xml:lang' => array(), + 'lang' => array() + ), + 'dl' => array(), + 'dt' => array(), + 'em' => array(), + 'fieldset' => array(), + 'font' => array( + 'color' => array(), 'face' => array(), + 'size' => array() + ), + 'form' => array( + 'action' => array(), 'accept' => array(), + 'accept-charset' => array(), 'enctype' => array(), + 'method' => array(), 'name' => array(), + 'target' => array() + ), + 'h1' => array( + 'align' => array() + ), + 'h2' => array( + 'align' => array() + ), + 'h3' => array( + 'align' => array() + ), + 'h4' => array( + 'align' => array() + ), + 'h5' => array( + 'align' => array() + ), + 'h6' => array( + 'align' => array() + ), + 'hr' => array( + 'align' => array(), 'noshade' => array(), + 'size' => array(), 'width' => array() + ), + 'i' => array(), + 'img' => array( + 'alt' => array(), 'align' => array(), + 'border' => array(), 'height' => array(), + 'hspace' => array(), 'longdesc' => array(), + 'vspace' => array(), 'src' => array(), + 'width' => array() + ), + 'ins' => array( + 'datetime' => array(), 'cite' => array() + ), + 'kbd' => array(), + 'label' => array( + 'for' => array() + ), + 'legend' => array( + 'align' => array() + ), + 'li' => array(), + 'p' => array( + 'align' => array(), 'xml:lang' => array(), + 'lang' => array() + ), + 'pre' => array( + 'width' => array() + ), 'q' => array( - 'cite' => array ()), - 'strike' => array (), - 'strong' => array (), - // 'sub' => array(), - // 'sup' => array(), - // 'u' => array(), - // 'ul' => array(), + 'cite' => array() + ), + 's' => array(), + 'strike' => array(), + 'strong' => array(), + 'sub' => array(), + 'sup' => array(), + 'table' => array( + 'align' => array(), 'bgcolor' => array(), + 'border' => array(), 'cellpadding' => array(), + 'cellspacing' => array(), 'rules' => array(), + 'summary' => array(), 'width' => array() + ), + 'tbody' => array( + 'align' => array(), 'char' => array(), + 'charoff' => array(), 'valign' => array() + ), + 'td' => array( + 'abbr' => array(), 'align' => array(), + 'axis' => array(), 'bgcolor' => array(), + 'char' => array(), 'charoff' => array(), + 'colspan' => array(), 'headers' => array(), + 'height' => array(), 'nowrap' => array(), + 'rowspan' => array(), 'scope' => array(), + 'valign' => array(), 'width' => array() + ), + 'textarea' => array( + 'cols' => array(), 'rows' => array(), + 'disabled' => array(), 'name' => array(), + 'readonly' => array() + ), + 'tfoot' => array( + 'align' => array(), 'char' => array(), + 'charoff' => array(), 'valign' => array() + ), + 'th' => array( + 'abbr' => array(), 'align' => array(), + 'axis' => array(), 'bgcolor' => array(), + 'char' => array(), 'charoff' => array(), + 'colspan' => array(), 'headers' => array(), + 'height' => array(), 'nowrap' => array(), + 'rowspan' => array(), 'scope' => array(), + 'valign' => array(), 'width' => array() + ), + 'thead' => array( + 'align' => array(), 'char' => array(), + 'charoff' => array(), 'valign' => array() + ), + 'title' => array(), + 'tr' => array( + 'align' => array(), 'bgcolor' => array(), + 'char' => array(), 'charoff' => array(), + 'valign' => array() + ), + 'tt' => array(), + 'u' => array(), + 'ul' => array(), + 'ol' => array(), + 'var' => array() + ); + + $allowedtags = array( + 'a' => array( + 'href' => array(), 'title' => array() + ), + 'abbr' => array( + 'title' => array() + ), + 'acronym' => array( + 'title' => array() + ), + 'b' => array(), + 'blockquote' => array( + 'cite' => array() + ), + // 'br' => array(), + 'code' => array(), + // 'del' => array('datetime' => array()), + // 'dd' => array(), + // 'dl' => array(), + // 'dt' => array(), + 'em' => array(), + 'i' => array(), + // 'ins' => array('datetime' => array(), 'cite' => array()), + // 'li' => array(), + // 'ol' => array(), + // 'p' => array(), + // 'q' => array(), + 'strike' => array(), + 'strong' => array(), + // 'sub' => array(), + // 'sup' => array(), + // 'u' => array(), + // 'ul' => array(), ); } + function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet')) ############################################################################### # This function makes sure that only the allowed HTML element names, attribute diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 0847ea3..4dba679 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -17,8 +17,7 @@ function get_locale() { return $locale; } -// Return a translated string. -function __($text, $domain = 'default') { +function translate($text, $domain) { global $l10n; if (isset($l10n[$domain])) @@ -27,29 +26,24 @@ function __($text, $domain = 'default') { return $text; } +// Return a translated string. +function __($text, $domain = 'default') { + return translate($text, $domain); +} + // Echo a translated string. function _e($text, $domain = 'default') { - global $l10n; - - if (isset($l10n[$domain])) - echo apply_filters('gettext', $l10n[$domain]->translate($text), $text); - else - echo $text; + echo translate($text, $domain); } function _c($text, $domain = 'default') { - global $l10n; - - if ( isset($l10n[$domain]) ) - $whole = apply_filters('gettext', $l10n[$domain]->translate($text), $text); - else - $whole = $text; - - $trans = explode('|', $whole, 2); - if ( isset( $trans[1] ) ) - return $trans[1]; - else - return $trans[0]; + $whole = translate($text, $domain); + $last_bar = strrpos($whole, '|'); + if ( false == $last_bar ) { + return $whole; + } else { + return substr($whole, 0, $last_bar); + } } // Return the plural form. @@ -57,7 +51,7 @@ function __ngettext($single, $plural, $number, $domain = 'default') { global $l10n; if (isset($l10n[$domain])) { - return $l10n[$domain]->ngettext($single, $plural, $number); + return apply_filters('ngettext', $l10n[$domain]->ngettext($single, $plural, $number), $single, $plural, $number); } else { if ($number != 1) return $plural; diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index a7f9601..99b8ae0 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -109,7 +109,7 @@ function get_permalink($id = 0) { } // get permalink from post ID -function post_permalink($post_id = 0, $mode = '') { // $mode legacy +function post_permalink($post_id = 0, $deprecated = '') { return get_permalink($post_id); } @@ -273,39 +273,80 @@ function get_post_comments_feed_link($post_id = '', $feed = 'rss2') { return apply_filters('post_comments_feed_link', $url); } -function edit_post_link($link = 'Edit This', $before = '', $after = '') { +function get_edit_post_link( $id = 0 ) { + $post = &get_post( $id ); + + if ( $post->post_type == 'attachment' ) { + return; + } elseif ( $post->post_type == 'page' ) { + if ( !current_user_can( 'edit_page', $post->ID ) ) + return; + + $file = 'page'; + } else { + if ( !current_user_can( 'edit_post', $post->ID ) ) + return; + + $file = 'post'; + } + + return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&post=' . $post->ID, $post->ID ); +} + +function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) { global $post; - if ( is_attachment() ) + if ( $post->post_type == 'attachment' ) { return; - - if( $post->post_type == 'page' ) { - if ( ! current_user_can('edit_page', $post->ID) ) + } elseif ( $post->post_type == 'page' ) { + if ( !current_user_can( 'edit_page', $post->ID ) ) return; + $file = 'page'; } else { - if ( ! current_user_can('edit_post', $post->ID) ) + if ( !current_user_can( 'edit_post', $post->ID ) ) return; + $file = 'post'; } - $location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID"; - echo $before . "$link" . $after; + $link = '' . $link . ''; + echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; } -function edit_comment_link($link = 'Edit This', $before = '', $after = '') { - global $post, $comment; +function get_edit_comment_link( $comment_id = 0 ) { + $comment = &get_comment( $comment_id ); + $post = &get_post( $comment->comment_post_ID ); + + if ( $post->post_type == 'attachment' ) { + return; + } elseif ( $post->post_type == 'page' ) { + if ( !current_user_can( 'edit_page', $post->ID ) ) + return; + } else { + if ( !current_user_can( 'edit_post', $post->ID ) ) + return; + } - if( $post->post_type == 'page' ){ - if ( ! current_user_can('edit_page', $post->ID) ) + $location = get_bloginfo( 'wpurl' ) . '/wp-admin/comment.php?action=editcomment&c=' . $comment->comment_ID; + return apply_filters( 'get_edit_comment_link', $location ); +} + +function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { + global $comment, $post; + + if ( $post->post_type == 'attachment' ) { + return; + } elseif ( $post->post_type == 'page' ) { + if ( !current_user_can( 'edit_page', $post->ID ) ) return; } else { - if ( ! current_user_can('edit_post', $post->ID) ) + if ( !current_user_can( 'edit_post', $post->ID ) ) return; } - $location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&c=$comment->comment_ID"; - echo $before . "$link" . $after; + $link = '' . $link . ''; + echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; } // Navigation links @@ -422,73 +463,55 @@ function next_post_link($format='%link »', $link='%title', $in_same_cat = function get_pagenum_link($pagenum = 1) { global $wp_rewrite; - - $qstr = $_SERVER['REQUEST_URI']; - - $page_querystring = "paged"; - $page_modstring = "page/"; - $page_modregex = "page/?"; - $permalink = 0; - + + $pagenum = (int) $pagenum; + + $request = remove_query_arg( 'paged' ); + $home_root = parse_url(get_option('home')); $home_root = $home_root['path']; - $home_root = trailingslashit($home_root); - $qstr = preg_replace('|^'. $home_root . '|', '', $qstr); - $qstr = preg_replace('|^/+|', '', $qstr); - - $index = $_SERVER['PHP_SELF']; - $index = preg_replace('|^'. $home_root . '|', '', $index); - $index = preg_replace('|^/+|', '', $index); - - // if we already have a QUERY style page string - if ( stristr( $qstr, $page_querystring ) ) { - $replacement = "$page_querystring=$pagenum"; - $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr); - // if we already have a mod_rewrite style page string - } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ) { - $permalink = 1; - $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr); - - // if we don't have a page string at all ... - // lets see what sort of URL we have... + $home_root = preg_quote( trailingslashit( $home_root ), '|' ); + + $request = preg_replace('|^'. $home_root . '|', '', $request); + $request = preg_replace('|^/+|', '', $request); + + if ( !$wp_rewrite->using_permalinks() ) { + $base = trailingslashit( get_bloginfo( 'home' ) ); + + if ( $pagenum > 1 ) { + $result = add_query_arg( 'paged', $pagenum, $base . $request ); + } else { + $result = $base . $request; + } } else { - // we need to know the way queries are being written - // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten - if ( stristr( $qstr, '?' ) ) { - // so append the query string (using &, since we already have ?) - $qstr .= '&' . $page_querystring . '=' . $pagenum; - // otherwise, it could be rewritten, OR just the default index ... - } elseif( '' != get_option('permalink_structure') && ! is_admin() ) { - $permalink = 1; - $index = $wp_rewrite->index; - // If it's not a path info permalink structure, trim the index. - if ( !$wp_rewrite->using_index_permalinks() ) { - $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr); - } else { - // If using path info style permalinks, make sure the index is in - // the URL. - if ( strpos($qstr, $index) === false ) - $qstr = '/' . $index . $qstr; - } - - $qstr = trailingslashit($qstr) . $page_modstring . $pagenum; + $request = preg_replace( '|/?page/(.+)/?$|', '', $request); + + $qs_regex = '|\?.*?$|'; + preg_match( $qs_regex, $request, $qs_match ); + + if ( $qs_match[0] ) { + $query_string = $qs_match[0]; + $request = preg_replace( $qs_regex, '', $request ); } else { - $qstr = $index . '?' . $page_querystring . '=' . $pagenum; + $query_string = ''; } + + $base = trailingslashit( get_bloginfo( 'url' ) ); + + if ( $wp_rewrite->using_index_permalinks() && $pagenum > 1 ) { + $base .= 'index.php/'; + } + + if ( $pagenum > 1 ) { + $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' ); + } else { + $request = user_trailingslashit( $request ); + } + + $result = $base . $request . $query_string; } - - $qstr = preg_replace('|^/+|', '', $qstr); - if ( $permalink ) - $qstr = user_trailingslashit($qstr, 'paged'); - $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_option('home') ) . $qstr ); - - // showing /page/1/ or ?paged=1 is redundant - if ( 1 === $pagenum ) { - $qstr = str_replace(user_trailingslashit('index.php/page/1', 'paged'), '', $qstr); // for PATHINFO style - $qstr = str_replace(user_trailingslashit('page/1', 'paged'), '', $qstr); // for mod_rewrite style - $qstr = remove_query_arg('paged', $qstr); // for query style - } - return $qstr; + + return $result; } function get_next_posts_page_link($max_page = 0) { diff --git a/wp-includes/locale.php b/wp-includes/locale.php index 0c8ec8b..af3fc13 100644 --- a/wp-includes/locale.php +++ b/wp-includes/locale.php @@ -87,6 +87,18 @@ class WP_Locale { $this->meridiem['AM'] = __('AM'); $this->meridiem['PM'] = __('PM'); + // Numbers formatting + // See http://php.net/number_format + + $trans = __('number_format_decimals'); + $this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans; + + $trans = __('number_format_decimal_point'); + $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans; + + $trans = __('number_format_thousands_sep'); + $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans; + // Import global locale vars set during inclusion of $locale.php. foreach ( $this->locale_vars as $var ) { if ( isset($GLOBALS[$var]) ) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 5f00e1d..949e603 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -121,6 +121,8 @@ function get_userdatabylogin($user_login) { if ( $userdata ) return $userdata; + $user_login = $wpdb->escape($user_login); + if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) return false; diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 61580e7..b8bf524 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -1,25 +1,53 @@ $function_to_add to. + * @param callback $function_to_add The name of the function to be called when the filter is applied. + * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. + * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. + * @return boolean true if the $function_to_add is added succesfully to filter $tag. How many arguments your function takes. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the action comment_id_not_found will pass any functions that hook onto it the ID of the requested comment. + */ function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { - global $wp_filter; + global $wp_filter, $merged_filters; // So the format is wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] $wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); + unset( $merged_filters[ $tag ] ); return true; } +/** + * Call the functions added to a filter hook. + * + * The callback functions attached to filter hook $tag are invoked by + * calling this function. This function can be used to create a new filter hook + * by simply calling this function with the name of the new hook specified using + * the $tag parameter. + * @uses merge_filters Merges the filter hooks using this function. + * @param string $tag The name of the filter hook. + * @param string $string The text on which the filters hooked to $tag are applied on. + * @param mixed $var,... Additional variables passed to the functions hooked to $tag. + * @return string The text in $string after all hooked functions are applied to it. + */ function apply_filters($tag, $string) { - global $wp_filter; + global $wp_filter, $merged_filters; - merge_filters($tag); + if ( !isset( $merged_filters[ $tag ] ) ) + merge_filters($tag); if ( !isset($wp_filter[$tag]) ) return $string; + reset( $wp_filter[ $tag ] ); + $args = func_get_args(); do{ @@ -34,37 +62,87 @@ function apply_filters($tag, $string) { return $string; } +/** + * Merge the filter functions of a specific filter hook with generic filter functions. + * + * It is possible to defined generic filter functions using the filter hook + * all. These functions are called for every filter tag. This function + * merges the functions attached to the all hook with the functions + * of a specific hoook defined by $tag. + * @param string $tag The filter hook of which the functions should be merged. + */ function merge_filters($tag) { - global $wp_filter; + global $wp_filter, $merged_filters; - if ( isset($wp_filter['all']) ) + if ( isset($wp_filter['all']) && is_array($wp_filter['all']) ) $wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]); if ( isset($wp_filter[$tag]) ){ reset($wp_filter[$tag]); uksort($wp_filter[$tag], "strnatcasecmp"); } + $merged_filters[ $tag ] = true; } +/** + * Removes a function from a specified filter hook. + * + * This function removes a function attached to a specified filter hook. This + * method can be used to remove default functions attached to a specific filter + * hook and possibly replace them with a substitute. + * @param string $tag The filter hook to which the function to be removed is hooked. + * @param callback $function_to_remove The name of the function which should be removed. + * @param int $priority optional. The priority of the function (default: 10). + * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). + * @return boolean Whether the function is removed. + */ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { - global $wp_filter; + $function_to_remove = serialize($function_to_remove); - unset($GLOBALS['wp_filter'][$tag][$priority][serialize($function_to_remove)]); + $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); - return true; -} + unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); + unset($GLOBALS['merged_filters'][$tag]); -// -// Action functions -// + return $r; +} +/** + * Hooks a function on to a specific action. + * + * Actions are the hooks that the WordPress core launches at specific points + * during execution, or when specific events occur. Plugins can specify that + * one or more of its PHP functions are executed at these points, using the + * Action API. + * + * @param string $tag The name of the action to which the $function_to-add is hooked. + * @param callback $function_to_add The name of the function you wish to be called. Note: any of the syntaxes explained in the PHP documentation for the 'callback' type (http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback) are valid. + * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. + * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. + * @return boolean Always true. + */ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { add_filter($tag, $function_to_add, $priority, $accepted_args); } +/** + * Execute functions hooked on a specific action hook. + * + * This function invokes all functions attached to action hook $tag. + * It is possible to create new action hooks by simply calling this function, + * specifying the name of the new hook using the $tag parameter. + * @uses merge_filters + * @param string $tag The name of the action to be executed. + * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. + */ function do_action($tag, $arg = '') { global $wp_filter, $wp_actions; + if ( is_array($wp_actions) ) + $wp_actions[] = $tag; + else + $wp_actions = array($tag); + $args = array(); if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this) $args[] =& $arg[0]; @@ -85,19 +163,30 @@ function do_action($tag, $arg = '') { } while ( next($wp_filter[$tag]) ); - if ( is_array($wp_actions) ) - $wp_actions[] = $tag; - else - $wp_actions = array($tag); } -// Returns the number of times an action has been done +/** + * Return the number times an action is fired. + * @param string $tag The name of the action hook. + * @return int The number of times action hook $tag is fired + */ function did_action($tag) { global $wp_actions; + if ( empty($wp_actions) ) + return 0; + return count(array_keys($wp_actions, $tag)); } +/** + * Execute functions hooked on a specific action hook, specifying arguments in a array. + * + * This function is identical to {@link do_action}, but the argumetns passe to + * the functions hooked to $tag are supplied using an array. + * @param string $tag The name of the action to be executed. + * @param array $args The arguments supplied to the functions hooked to $tag + */ function do_action_ref_array($tag, $args) { global $wp_filter, $wp_actions; @@ -120,25 +209,72 @@ function do_action_ref_array($tag, $args) { } +/** + * Removes a function from a specified action hook. + * + * This function removes a function attached to a specified action hook. This + * method can be used to remove default functions attached to a specific filter + * hook and possibly replace them with a substitute. + * @param string $tag The action hook to which the function to be removed is hooked. + * @param callback $function_to_remove The name of the function which should be removed. + * @param int $priority optional The priority of the function (default: 10). + * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). + * @return boolean Whether the function is removed. + */ function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { - remove_filter($tag, $function_to_remove, $priority, $accepted_args); + return remove_filter($tag, $function_to_remove, $priority, $accepted_args); } // // Functions for handling plugins. // +/** + * Gets the basename of a plugin. + * + * This method extract the name of a plugin from its filename. + * @param string $file The filename of plugin. + * @return string The name of a plugin. + */ function plugin_basename($file) { $file = preg_replace('|\\\\+|', '\\\\', $file); $file = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file); return $file; } +/** + * Hook a function on a plugin activation action hook. + * + * When a plugin is activated, the action 'activate_PLUGINNAME' hook is + * activated. In the name of this hook, PLUGINNAME is replaced with the name of + * the plugin, including the optional subdirectory. For example, when the plugin + * is located in wp-content/plugin/sampleplugin/sample.php, then the + * name of this hook will become 'activate_sampleplugin/sample.php'. + * When the plugin consists of only one file and is (as by default) located at + * wp-content/plugin/sample.php the name of this hook will be + * 'activate_sample.php'. + * @param string $file The filename of the plugin including the path. + * @param string $function the function hooked to the 'activate_PLUGIN' action. + */ function register_activation_hook($file, $function) { $file = plugin_basename($file); add_action('activate_' . $file, $function); } +/** + * Hook a function on a plugin deactivation action hook. + * + * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is + * deactivated. In the name of this hook, PLUGINNAME is replaced with the name of + * the plugin, including the optional subdirectory. For example, when the plugin + * is located in wp-content/plugin/sampleplugin/sample.php, then the + * name of this hook will become 'activate_sampleplugin/sample.php'. + * When the plugin consists of only one file and is (as by default) located at + * wp-content/plugin/sample.php the name of this hook will be + * 'activate_sample.php'. + * @param string $file The filename of the plugin including the path. + * @param string $function the function hooked to the 'activate_PLUGIN' action. + */ function register_deactivation_hook($file, $function) { $file = plugin_basename($file); add_action('deactivate_' . $file, $function); diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 94d2876..cee198b 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -80,7 +80,7 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_ $page = count($pages); // give them the highest numbered page that DOES exist $content = $pages[$page-1]; - if ( preg_match('//', $content, $matches) ) { + if ( preg_match('//', $content, $matches) ) { $content = explode($matches[0], $content, 2); if ( !empty($matches[1]) && !empty($more_link_text) ) $more_link_text = strip_tags(wp_kses_no_null(trim($matches[1]))); @@ -129,19 +129,23 @@ function get_the_excerpt($fakeit = true) { return apply_filters('get_the_excerpt', $output); } +function has_excerpt( $id = 0 ) { + $post = &get_post( $id ); + return ( !empty( $post->post_excerpt ) ); +} function wp_link_pages($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('before' => '

    ' . __('Pages:'), 'after' => '

    ', 'next_or_number' => 'number', 'nextpagelink' => __('Next page'), - 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'more_file' => '', 'echo' => 1); - $r = array_merge($defaults, $r); - extract($r); - - global $id, $page, $numpages, $multipage, $more, $pagenow; + $defaults = array( + 'before' => '

    ' . __('Pages:'), 'after' => '

    ', + 'next_or_number' => 'number', 'nextpagelink' => __('Next page'), + 'previouspagelink' => __('Previous page'), 'pagelink' => '%', + 'more_file' => '', 'echo' => 1 + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r ); + + global $post, $id, $page, $numpages, $multipage, $more, $pagenow; if ( $more_file != '' ) $file = $more_file; else @@ -158,7 +162,7 @@ function wp_link_pages($args = '') { if ( 1 == $i ) { $output .= ''; } else { - if ( '' == get_option('permalink_structure') ) + if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) $output .= ''; else $output .= ''; @@ -177,7 +181,7 @@ function wp_link_pages($args = '') { if ( 1 == $i ) { $output .= '' . $previouspagelink . ''; } else { - if ( '' == get_option('permalink_structure') ) + if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) $output .= '' . $previouspagelink . ''; else $output .= '' . $previouspagelink . ''; @@ -188,7 +192,7 @@ function wp_link_pages($args = '') { if ( 1 == $i ) { $output .= '' . $nextpagelink . ''; } else { - if ( '' == get_option('permalink_structure') ) + if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) $output .= '' . $nextpagelink . ''; else $output .= '' . $nextpagelink . ''; @@ -233,7 +237,7 @@ function the_meta() { continue; $values = array_map('trim', get_post_custom_values($key)); $value = implode($values,', '); - echo "
  • $value
  • \n"; + echo apply_filters('the_meta_key', "
  • $value
  • \n", $key, $value); } echo "\n"; } @@ -245,15 +249,14 @@ function the_meta() { // function wp_dropdown_pages($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, - 'name' => 'page_id', 'show_option_none' => ''); - $r = array_merge($defaults, $r); - extract($r); + $defaults = array( + 'depth' => 0, 'child_of' => 0, + 'selected' => 0, 'echo' => 1, + 'name' => 'page_id', 'show_option_none' => '' + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r ); $pages = get_pages($r); $output = ''; @@ -275,14 +278,16 @@ function wp_dropdown_pages($args = '') { } function wp_list_pages($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), - 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title'); - $r = array_merge($defaults, $r); + $defaults = array( + 'depth' => 0, 'show_date' => '', + 'date_format' => get_option('date_format'), + 'child_of' => 0, 'exclude' => '', + 'title_li' => __('Pages'), 'echo' => 1, + 'authors' => '', 'sort_column' => 'menu_order, post_title' + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r ); $output = ''; $current_page = 0; @@ -345,7 +350,7 @@ function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false) $id = (int) $id; $_post = & get_post($id); - if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url() ) + if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) return __('Missing Attachment'); $post_title = attribute_escape($_post->post_title); diff --git a/wp-includes/post.php b/wp-includes/post.php index 0c0dfb6..9c6929a 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -27,23 +27,25 @@ function update_attached_file( $attachment_id, $file ) { function &get_children($args = '', $output = OBJECT) { global $post_cache, $wpdb, $blog_id; - - if ( empty($args) ) { - if ( isset($GLOBALS['post']) ) - $r = array('post_parent' => & $GLOBALS['post']->post_parent); - else + + if ( empty( $args ) ) { + if ( isset( $GLOBALS['post'] ) ) { + $args = 'post_parent=' . (int) $GLOBALS['post']->post_parent; + } else { return false; - } elseif ( is_object($args) ) - $r = array('post_parent' => $post->post_parent); - elseif ( is_numeric($args) ) - $r = array('post_parent' => $args); - elseif ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('numberposts' => -1, 'post_type' => '', 'post_status' => '', 'post_parent' => 0); - $r = array_merge($defaults, $r); + } + } elseif ( is_object( $args ) ) { + $args = 'post_parent=' . (int) $args->post_parent; + } elseif ( is_numeric( $args ) ) { + $args = 'post_parent=' . (int) $args; + } + + $defaults = array( + 'numberposts' => -1, 'post_type' => '', + 'post_status' => '', 'post_parent' => 0 + ); + + $r = wp_parse_args( $args, $defaults ); $children = get_posts( $r ); @@ -74,7 +76,7 @@ function &get_children($args = '', $output = OBJECT) { // get extended entry info () function get_extended($post) { //Match the new style more links - if ( preg_match('//', $post, $matches) ) { + if ( preg_match('//', $post, $matches) ) { list($main, $extended) = explode($matches[0], $post, 2); } else { $main = $post; @@ -172,17 +174,19 @@ function get_post_type($post = false) { function get_posts($args) { global $wpdb; - - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => 0, - 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', - 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'publish', 'post_parent' => 0); - $r = array_merge($defaults, $r); - extract($r); + + $defaults = array( + 'numberposts' => 5, 'offset' => 0, + 'category' => 0, 'orderby' => 'post_date', + 'order' => 'DESC', 'include' => '', + 'exclude' => '', 'meta_key' => '', + 'meta_value' =>'', 'post_type' => 'post', + 'post_status' => 'publish', 'post_parent' => 0 + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r ); + $numberposts = (int) $numberposts; $offset = (int) $offset; $category = (int) $category; @@ -225,14 +229,6 @@ function get_posts($args) { 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 = "SELECT DISTINCT * FROM $wpdb->posts "; $query .= empty( $category ) ? '' : ", $wpdb->post2cat "; $query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta "; @@ -443,8 +439,8 @@ function wp_delete_post($postid = 0) { $wp_rewrite->flush_rules(); } - do_action('post_deleted', $postid); - + do_action('deleted_post', $postid); + return $post; } @@ -653,7 +649,7 @@ function wp_insert_post($postarr = array()) { $wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" ); } - wp_set_post_categories($post_ID, $post_category); + wp_set_post_categories( $post_ID, $post_category ); if ( 'page' == $post_type ) { clean_page_cache($post_ID); @@ -1066,16 +1062,17 @@ function get_page_uri($page_id) { function &get_pages($args = '') { global $wpdb; - - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', - 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => ''); - $r = array_merge($defaults, $r); - extract($r); + + $defaults = array( + 'child_of' => 0, 'sort_order' => 'ASC', + 'sort_column' => 'post_title', 'hierarchical' => 1, + 'exclude' => '', 'include' => '', + 'meta_key' => '', 'meta_value' => '', + 'authors' => '' + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r ); $key = md5( serialize( $r ) ); if ( $cache = wp_cache_get( 'get_pages', 'page' ) ) @@ -1568,4 +1565,50 @@ function wp_check_for_changed_slugs($post_id) { return $post_id; } +/** + * This function provides a standardized way to appropriately select on + * the post_status of posts/pages. The function will return a piece of + * SQL code that can be added to a WHERE clause; this SQL is constructed + * to allow all published posts, and all private posts to which the user + * has access. + * + * @param string $post_type currently only supports 'post' or 'page'. + * @return string SQL code that can be added to a where clause. + */ +function get_private_posts_cap_sql($post_type) { + global $user_ID; + $cap = ''; + + // Private posts + if ($post_type == 'post') { + $cap = 'read_private_posts'; + // Private pages + } elseif ($post_type == 'page') { + $cap = 'read_private_pages'; + // Dunno what it is, maybe plugins have their own post type? + } else { + $cap = apply_filters('pub_priv_sql_capability', $cap); + + if (empty($cap)) { + // We don't know what it is, filters don't change anything, + // so set the SQL up to return nothing. + return '1 = 0'; + } + } + + $sql = '(post_status = \'publish\''; + + if (current_user_can($cap)) { + // Does the user have the capability to view private posts? Guess so. + $sql .= ' OR post_status = \'private\''; + } elseif (is_user_logged_in()) { + // Users can view their own private posts. + $sql .= ' OR post_status = \'private\' AND post_author = \'' . $user_ID . '\''; + } + + $sql .= ')'; + + return $sql; +} + ?> diff --git a/wp-includes/query.php b/wp-includes/query.php index 26e1afc..05dc692 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -888,6 +888,8 @@ class WP_Query { $groupby = "{$wpdb->posts}.ID"; } + + // Author/user stuff if ( empty($q['author']) || ($q['author'] == '0') ) { @@ -1023,7 +1025,7 @@ class WP_Query { $cwhere = apply_filters('comment_feed_where', $cwhere); $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); - $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss')); + $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss')); $this->comment_count = count($this->comments); $post_ids = array(); @@ -1062,7 +1064,7 @@ class WP_Query { if ( $this->is_comment_feed && $this->is_singular ) { $cjoin = apply_filters('comment_feed_join', ''); $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'"); - $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss'); + $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'); $this->comments = $wpdb->get_results($comments_request); $this->comment_count = count($this->comments); } diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index d22d3fc..eb10bf7 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -46,11 +46,11 @@ define('EP_ROOT', 64 ); define('EP_COMMENTS', 128 ); define('EP_SEARCH', 256 ); define('EP_CATEGORIES', 512 ); -define('EP_AUTHORS', 1024); -define('EP_PAGES', 2048); +define('EP_AUTHORS', 2048); +define('EP_PAGES', 4096); //pseudo-places define('EP_NONE', 0 ); -define('EP_ALL', 255); +define('EP_ALL', 8191); //and an endpoint, like /trackback/ function add_rewrite_endpoint($name, $places) { @@ -62,6 +62,8 @@ function add_rewrite_endpoint($name, $places) { // determine the post ID it represents. function url_to_postid($url) { global $wp_rewrite; + + $url = apply_filters('url_to_postid', $url); // First, check to see if there is a 'p=N' or 'page_id=N' to match against preg_match('#[?&](p|page_id)=(\d+)#', $url, $values); @@ -197,6 +199,7 @@ class WP_Rewrite { '([^/]+)', '([0-9]+)', '(.+?)', + '(.+?)', '([^/]+)', '([^/]+)', '(.+)' @@ -582,6 +585,16 @@ class WP_Rewrite { if ($paged) //...and /page/xx ones $rewrite = array_merge($rewrite, array($pagematch => $pagequery)); + //do endpoints + if ($endpoints) { + foreach ($ep_query_append as $regex => $ep) { + //add the endpoints on if the mask fits + if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) { + $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); + } + } + } + //if we've got some tags in this dir if ($num_toks) { $post = false; @@ -599,16 +612,6 @@ class WP_Rewrite { $page = true; } - //do endpoints - if ($endpoints) { - foreach ($ep_query_append as $regex => $ep) { - //add the endpoints on if the mask fits - if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) { - $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); - } - } - } - //if we're creating rules for a permalink, do all the endpoints like attachments etc if ($post) { $post = true; @@ -869,7 +872,7 @@ class WP_Rewrite { if ($this->using_index_permalinks()) { $this->root = $this->index . '/'; } - $this->category_base = get_option('category_base'); + $this->category_base = get_option( 'category_base' ); unset($this->category_structure); unset($this->author_structure); unset($this->date_structure); diff --git a/wp-includes/rss.php b/wp-includes/rss.php index 44005a7..da7bc1b 100644 --- a/wp-includes/rss.php +++ b/wp-includes/rss.php @@ -815,7 +815,8 @@ function parse_w3cdtf ( $date_str ) { else { return -1; } - } +} + function wp_rss ($url, $num_items) { //ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned. $rss = fetch_rss($url); @@ -832,7 +833,7 @@ function wp_rss ($url, $num_items) { echo ""; } else { - echo "an error has occured the feed is probably down, try again later."; + echo 'An error has occurred the feed is probably down, try again later.'; } } diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index c4a318a..bc180cf 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -11,14 +11,32 @@ class WP_Scripts { function default_scripts() { $this->add( 'dbx', '/wp-includes/js/dbx.js', false, '2.05' ); + $this->add( 'fat', '/wp-includes/js/fat.js', false, '1.0-RC1_3660' ); + $this->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); - $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3517' ); + + $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3958' ); + $this->localize( 'quicktags', 'quicktagsL10n', array( + 'quickLinks' => __('(Quick Links)'), + 'wordLookup' => __('Enter a word to look up:'), + 'dictionaryLookup' => attribute_escape(__('Dictionary lookup')), + 'lookup' => attribute_escape(__('lookup')), + 'closeAllOpenTags' => attribute_escape(__('Close all open tags')), + 'closeTags' => attribute_escape(__('close tags')), + 'enterURL' => __('Enter the URL'), + 'enterImageURL' => __('Enter the URL of the image'), + 'enterImageDescription' => __('Enter a description of the image') + ) ); + $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); + $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070326' ); $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070225' ); - $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0-0'); + + $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.1'); + $this->add( 'autosave', '/wp-includes/js/autosave.js', array('prototype', 'sack'), '20070306'); $this->localize( 'autosave', 'autosaveL10n', array( 'autosaveInterval' => apply_filters('autosave_interval', '120'), @@ -27,6 +45,7 @@ class WP_Scripts { 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', 'savingText' => __('Saving Draft...') ) ); + $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306'); $this->localize( 'wp-ajax', 'WPAjaxL10n', array( 'defaultUrl' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', @@ -34,21 +53,27 @@ class WP_Scripts { 'strangeText' => __("Something strange happened. Try refreshing the page."), 'whoaText' => __("Slow down, I'm still sending your data!") ) ); - $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306'); + + $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306' ); $this->localize( 'listman', 'listManL10n', array( 'jumpText' => __('Jump to new item'), 'delText' => __('Are you sure you want to delete this %thing%?') ) ); - $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0'); - $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0'); - $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.0'); - $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.0'); - $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.0'); - $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.0'); - $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.0'); + + $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.1-b2'); + $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.1-b2'); + $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.1-b2'); + $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.1-b2'); + $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.1-b2'); + $this->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.7.1-b2' ); + $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.1-b2'); + $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.1-b2'); + $this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); - $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.1'); - $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.1.1'); + + $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.2'); + $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2'); + if ( is_admin() ) { global $pagenow; $man = false; @@ -67,7 +92,7 @@ class WP_Scripts { break; endswitch; if ( $man ) { - $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key.js', array('dbx'), '20070306' ); + $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key.js', array('dbx'), '20070417' ); $this->localize( 'dbx-admin-key', 'dbxL10n', array( 'manager' => $man, 'open' => __('open'), @@ -78,14 +103,14 @@ class WP_Scripts { 'toggleKey' => __(', or press the enter key to %toggle% it'), ) ); } - $this->add( 'ajaxcat', '/wp-admin/cat.js', array('listman'), '20070306' ); + $this->add( 'ajaxcat', '/wp-admin/cat.js', array('listman'), '20070417' ); $this->localize( 'ajaxcat', 'catL10n', array( 'add' => attribute_escape(__('Add')), 'how' => __('Separate multiple categories with commas.') ) ); $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' ); $this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' ); - $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' ); + $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '20070327' ); $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' ); $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' ); $this->add( 'upload', '/wp-admin/upload.js', array('prototype'), '20070306' ); @@ -150,6 +175,12 @@ class WP_Scripts { if ( isset($this->args[$handle]) ) $ver .= '&' . $this->args[$handle]; $src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_option( 'siteurl' ) . $this->scripts[$handle]->src; + $src = $this->scripts[$handle]->src; + + if (!preg_match('|^https?://|', $src)) { + $src = get_option('siteurl') . $src; + } + $src = add_query_arg('ver', $ver, $src); $src = clean_url(apply_filters( 'script_loader_src', $src )); echo "\n"; diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 2a7ac8c..c251935 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -56,6 +56,21 @@ function get_template_directory_uri() { } function get_theme_data( $theme_file ) { + $themes_allowed_tags = array( + 'a' => array( + 'href' => array(),'title' => array() + ), + 'abbr' => array( + 'title' => array() + ), + 'acronym' => array( + 'title' => array() + ), + 'code' => array(), + 'em' => array(), + 'strong' => array() + ); + $theme_data = implode( '', file( $theme_file ) ); $theme_data = str_replace ( '\r', '\n', $theme_data ); preg_match( '|Theme Name:(.*)|i', $theme_data, $theme_name ); @@ -64,26 +79,28 @@ function get_theme_data( $theme_file ) { preg_match( '|Author:(.*)|i', $theme_data, $author_name ); preg_match( '|Author URI:(.*)|i', $theme_data, $author_uri ); preg_match( '|Template:(.*)|i', $theme_data, $template ); + if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) ) - $version = trim( $version[1] ); + $version = wp_kses( trim( $version[1] ), $themes_allowed_tags ); else - $version =''; + $version = ''; + if ( preg_match('|Status:(.*)|i', $theme_data, $status) ) - $status = trim($status[1]); + $status = wp_kses( trim( $status[1] ), $themes_allowed_tags ); else $status = 'publish'; - - $description = wptexturize( trim( $description[1] ) ); - - $name = $theme_name[1]; - $name = trim( $name ); - $theme = $name; - $theme_uri = trim( $theme_uri[1] ); - - if ( '' == $author_uri[1] ) { - $author = trim( $author_name[1] ); + + $name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags ); + $theme_uri = clean_url( trim( $theme_uri[1] ) ); + $description = wptexturize( wp_kses( trim( $description[1] ), $themes_allowed_tags ) ); + $template = wp_kses( trim( $template[1] ), $themes_allowed_tags ); + + $author_uri = clean_url( trim( $author_uri[1] ) ); + + if ( empty( $author_uri[1] ) ) { + $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags ); } else { - $author = '' . trim( $author_name[1] ) . ''; + $author = sprintf( '%3$s', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) ); } return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status ); @@ -163,6 +180,7 @@ function get_themes() { $template = $theme_data['Template']; $stylesheet = dirname($theme_file); + $screenshot = false; foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) { if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) { $screenshot = "screenshot.$ext"; diff --git a/wp-includes/user.php b/wp-includes/user.php index 14de35a..ca4006b 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -10,7 +10,7 @@ function get_profile($field, $user = false) { function get_usernumposts($userid) { global $wpdb; $userid = (int) $userid; - return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND post_status = 'publish'"); + return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND " . get_private_posts_cap_sql('post')); } // TODO: xmlrpc only. Maybe move to xmlrpc.php. diff --git a/wp-includes/vars.php b/wp-includes/vars.php index 0f749be..010d174 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -35,4 +35,50 @@ $is_IE = ( $is_macIE || $is_winIE ); $is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false; $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false; +$wp_header_to_desc = apply_filters( 'wp_header_to_desc_array', array( + 100 => 'Continue', + 101 => 'Switching Protocols', + + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + + 400 => 'Bad Request', + 401 => 'Unauthorized', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported' +) ); + ?> diff --git a/wp-includes/version.php b/wp-includes/version.php index 5355c5c..ca88592 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -3,6 +3,6 @@ // This holds the version number in a separate file so we can bump it without cluttering the SVN $wp_version = 'wordpress-mu-1.2.1'; // Let's just avoid confusion -$wp_db_version = 4860; +$wp_db_version = 5200; ?> diff --git a/wp-links-opml.php b/wp-links-opml.php index 4b72322..111ac8d 100644 --- a/wp-links-opml.php +++ b/wp-links-opml.php @@ -17,7 +17,7 @@ if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) { - Links for <?php echo get_bloginfo('name').$cat_name ?> + Links for <?php echo attribute_escape(get_bloginfo('name').$cat_name); ?> GMT diff --git a/wp-mail.php b/wp-mail.php index ded37bd..8795c74 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -24,10 +24,10 @@ for ($i=1; $i <= $count; $i++) : $content = ''; $content_type = ''; + $content_transfer_encoding = ''; $boundary = ''; $bodysignal = 0; - $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); + $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); foreach ($message as $line) : if (strlen($line) < 3) $bodysignal = 1; @@ -40,6 +40,12 @@ for ($i=1; $i <= $count; $i++) : $content_type = explode(';', $content_type); $content_type = $content_type[0]; } + if (preg_match('/Content-Transfer-Encoding: /i', $line)) { + $content_transfer_encoding = trim($line); + $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding)-14); + $content_transfer_encoding = explode(';', $content_transfer_encoding); + $content_transfer_encoding = $content_transfer_encoding[0]; + } if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) { $boundary = trim($line); $boundary = explode('"', $boundary); @@ -56,7 +62,7 @@ for ($i=1; $i <= $count; $i++) : // Set the author using the email address (To or Reply-To, the last used) // otherwise use the site admin - if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) { + if (preg_match('/From: /', $line) | preg_match('/Reply-To: /', $line)) { $author=trim($line); if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) { $author = $regs[1]; @@ -111,11 +117,16 @@ for ($i=1; $i <= $count; $i++) : $content = strip_tags($content[1], '


    '); } $content = trim($content); + + if (stripos($content_transfer_encoding, "quoted-printable") !== false) { + $content = quoted_printable_decode($content); + } + // Captures any text in the body after $phone_delim as the body $content = explode($phone_delim, $content); $content[1] ? $content = $content[1] : $content = $content[0]; - echo "

    Content-type: $content_type, boundary: $boundary

    \n"; + echo "

    Content-type: $content_type, Content-Transfer-Encoding: $content_transfer_encoding, boundary: $boundary

    \n"; echo "

    Raw content:

    ".$content.'

    '; $content = trim($content); diff --git a/wp-settings.php b/wp-settings.php index 25833c6..9fa1350 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -77,7 +77,7 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop( $mtime = $mtime[1] + $mtime[0]; $timeend = $mtime; $timetotal = $timeend-$timestart; - $r = number_format($timetotal, $precision); + $r = number_format_i18n($timetotal, $precision); if ( $display ) echo $r; return $r; @@ -89,7 +89,7 @@ error_reporting(E_ALL ^ E_NOTICE); // For an advanced caching plugin to use, static because you would only want one if ( defined('WP_CACHE') ) - require (ABSPATH . 'wp-content/advanced-cache.php'); + @include ABSPATH . 'wp-content/advanced-cache.php'; define('WPINC', 'wp-includes'); @@ -148,9 +148,9 @@ if ( defined('CUSTOM_USER_META_TABLE') ) $tableposts = $tableusers = $tablecategories = $tablepost2cat = $tablecomments = $tablelink2cat = $tablelinks = $tablelinkcategories = $tableoptions = $tablepostmeta = ''; if ( file_exists(ABSPATH . 'wp-content/object-cache.php') ) - require (ABSPATH . 'wp-content/object-cache.php'); + require_once (ABSPATH . 'wp-content/object-cache.php'); else - require (ABSPATH . WPINC . '/cache.php'); + require_once (ABSPATH . WPINC . '/cache.php'); // To disable persistant caching, add the below line to your wp-config.php file, uncommented of course. // define('DISABLE_CACHE', true); @@ -333,4 +333,4 @@ register_shutdown_function('shutdown_action_hook'); // Everything is loaded and initialized. do_action('init'); -?> +?> \ No newline at end of file diff --git a/xmlrpc.php b/xmlrpc.php index 41d5def..1283c7c 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -5,6 +5,12 @@ define('XMLRPC_REQUEST', true); // Some browser-embedded clients send cookies. We don't want them. $_COOKIE = array(); +// A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, +// but we can do it ourself. +if ( !isset( $HTTP_RAW_POST_DATA ) ) { + $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); +} + # fix for mozBlog and other cases where 'ping_status) ? 1 : 0; // Format page date. - $page_date = mysql2date("Ymd\TH:i:s", $page->post_date); + $page_date = mysql2date("Ymd\TH:i:s", $page->post_date_gmt); // Pull the categories info together. $categories = array(); @@ -423,7 +429,7 @@ class wp_xmlrpc_server extends IXR_Server { SELECT ID page_id, post_title page_title, post_parent page_parent_id, - post_date + post_date_gmt FROM {$wpdb->posts} WHERE post_type = 'page' ORDER BY ID @@ -432,10 +438,10 @@ class wp_xmlrpc_server extends IXR_Server { // The date needs to be formated properly. $num_pages = count($page_list); for($i = 0; $i < $num_pages; $i++) { - $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date); + $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt); $page_list[$i]->dateCreated = new IXR_Date($post_date); - unset($page_list[$i]->post_date); + unset($page_list[$i]->post_date_gmt); } return($page_list); @@ -569,8 +575,9 @@ class wp_xmlrpc_server extends IXR_Server { $user_login = $args[1]; $user_pass = $args[2]; - if (!$this->login_pass_ok($user_login, $user_pass)) + if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; + } $user = set_current_user(0, $user_login); @@ -949,12 +956,12 @@ class wp_xmlrpc_server extends IXR_Server { // Let WordPress generate the post_name (slug) unless // one has been provided. $post_name = ""; - if(!empty($content_struct["wp_slug"])) { + if(isset($content_struct["wp_slug"])) { $post_name = $content_struct["wp_slug"]; } // Only use a password if one was given. - if(!empty($content_struct["wp_password"])) { + if(isset($content_struct["wp_password"])) { $post_password = $content_struct["wp_password"]; } @@ -964,14 +971,17 @@ class wp_xmlrpc_server extends IXR_Server { } // Only set the menu_order if it was provided. - if(!empty($content_struct["wp_page_order"])) { + if(isset($content_struct["wp_page_order"])) { $menu_order = $content_struct["wp_page_order"]; } $post_author = $user->ID; // If an author id was provided then use it instead. - if(!empty($content_struct["wp_author_id"])) { + if( + isset($content_struct["wp_author_id"]) + && ($user->ID != $content_struct["wp_author_id"]) + ) { switch($post_type) { case "post": if(!current_user_can("edit_others_posts")) { @@ -999,13 +1009,33 @@ class wp_xmlrpc_server extends IXR_Server { $post_excerpt = $content_struct['mt_excerpt']; $post_more = $content_struct['mt_text_more']; - $comment_status = (!isset($content_struct['mt_allow_comments'])) ? - get_option('default_comment_status') - : $content_struct['mt_allow_comments']; + if(isset($content_struct["mt_allow_comments"])) { + switch((int) $content_struct["mt_allow_comments"]) { + case 0: + $comment_status = "closed"; + break; + case 1: + $comment_status = "open"; + break; + default: + $comment_status = get_option("default_comment_status"); + break; + } + } - $ping_status = (!isset($content_struct['mt_allow_pings'])) ? - get_option('default_ping_status') - : $content_struct['mt_allow_pings']; + if(isset($content_struct["mt_allow_pings"])) { + switch((int) $content_struct["mt_allow_pings"]) { + case 0: + $ping_status = "closed"; + break; + case 1: + $ping_status = "open"; + break; + default: + $ping_status = get_option("default_ping_status"); + break; + } + } if ($post_more) { $post_content = $post_content . "\n\n" . $post_more; @@ -1020,7 +1050,7 @@ class wp_xmlrpc_server extends IXR_Server { if (!empty($dateCreatedd)) { $dateCreated = $dateCreatedd->getIso(); $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); - $post_date_gmt = iso8601_to_datetime($dateCreated, GMT); + $post_date_gmt = iso8601_to_datetime($dateCreated. "Z", GMT); } else { $post_date = current_time('mysql'); $post_date_gmt = current_time('mysql', 1); @@ -1083,7 +1113,7 @@ class wp_xmlrpc_server extends IXR_Server { return $this->error; } - set_current_user(0, $user_login); + $user = set_current_user(0, $user_login); // The post_type defaults to post, but could also be page. $post_type = "post"; @@ -1112,12 +1142,12 @@ class wp_xmlrpc_server extends IXR_Server { // Let WordPress manage slug if none was provided. $post_name = ""; - if(!empty($content_struct["wp_slug"])) { + if(isset($content_struct["wp_slug"])) { $post_name = $content_struct["wp_slug"]; } // Only use a password if one was given. - if(!empty($content_struct["wp_password"])) { + if(isset($content_struct["wp_password"])) { $post_password = $content_struct["wp_password"]; } @@ -1127,12 +1157,17 @@ class wp_xmlrpc_server extends IXR_Server { } // Only set the menu_order if it was given. - if(!empty($content_struct["wp_page_order"])) { + if(isset($content_struct["wp_page_order"])) { $menu_order = $content_struct["wp_page_order"]; } + $post_author = $user->ID; + // Only set the post_author if one is set. - if(!empty($content_struct["wp_author_id"])) { + if( + isset($content_struct["wp_author_id"]) + && ($user->ID != $content_struct["wp_author_id"]) + ) { switch($post_type) { case "post": if(!current_user_can("edit_others_posts")) { @@ -1155,11 +1190,11 @@ class wp_xmlrpc_server extends IXR_Server { // Only set ping_status if it was provided. if(isset($content_struct["mt_allow_pings"])) { - switch($content_struct["mt_allow_pings"]) { - case "0": + switch((int) $content_struct["mt_allow_pings"]) { + case 0: $ping_status = "closed"; break; - case "1": + case 1: $ping_status = "open"; break; } @@ -1197,7 +1232,7 @@ class wp_xmlrpc_server extends IXR_Server { $to_ping = implode(' ', $to_ping); if(isset($content_struct["mt_allow_comments"])) { - $comment_status = $content_struct["mt_allow_comments"]; + $comment_status = (int) $content_struct["mt_allow_comments"]; } // Do some timestamp voodoo @@ -1205,7 +1240,7 @@ class wp_xmlrpc_server extends IXR_Server { if (!empty($dateCreatedd)) { $dateCreated = $dateCreatedd->getIso(); $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); - $post_date_gmt = iso8601_to_datetime($dateCreated, GMT); + $post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT); } else { $post_date = $postdata['post_date']; $post_date_gmt = $postdata['post_date_gmt']; @@ -1245,7 +1280,7 @@ class wp_xmlrpc_server extends IXR_Server { if ($postdata['post_date'] != '') { - $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); + $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']); $categories = array(); $catids = wp_get_post_categories($post_ID); @@ -1313,7 +1348,7 @@ class wp_xmlrpc_server extends IXR_Server { foreach ($posts_list as $entry) { - $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach($catids as $catid) { @@ -1498,7 +1533,7 @@ class wp_xmlrpc_server extends IXR_Server { foreach ($posts_list as $entry) { - $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']); $struct[] = array( 'dateCreated' => new IXR_Date($post_date), -- cgit