Changeset 817

Show
Ignore:
Timestamp:
12/01/06 12:27:29 (2 years ago)
Author:
donncha
Message:

WP Merge to 4578, except for script-loader

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/admin-ajax.php

    r810 r817  
    156156                die('-1'); 
    157157        if ( $id < 0 ) { 
    158                 if ( $pid = wp_insert_post() ) 
     158                $now = current_time('timestamp'); 
     159                if ( $pid = wp_insert_post( array( 
     160                        'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) 
     161                ) ) ) 
    159162                        $mid = add_meta( $pid ); 
    160163                else 
     
    182185        $value = $_POST['meta'][$mid]['value']; 
    183186        if ( !$meta = get_post_meta_by_id( $mid ) ) 
    184                 die('0'); 
     187                die('0'); // if meta doesn't exist 
    185188        if ( !current_user_can( 'edit_post', $meta->post_id ) ) 
    186189                die('-1'); 
     
    196199                $x->send(); 
    197200        } 
    198         die('0'); 
     201        die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). 
    199202        break; 
    200203case 'add-user' : 
  • trunk/wp-admin/admin-functions.php

    r816 r817  
    12691269 
    12701270        if (!$wp_rewrite->using_mod_rewrite_permalinks() ) 
    1271                 return
     1271                return false
    12721272 
    12731273        if (!((!file_exists( $home_path.'.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path.'.htaccess' ) ) ) 
    1274                 return
     1274                return false
    12751275 
    12761276        if (! got_mod_rewrite() ) 
    1277                 return
     1277                return false
    12781278 
    12791279        $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() ); 
    1280         insert_with_markers( $home_path.'.htaccess', 'WordPress', $rules ); 
     1280        return insert_with_markers( $home_path.'.htaccess', 'WordPress', $rules ); 
    12811281} 
    12821282 
     
    20982098                return $post_id; 
    20992099 
    2100         $old_slugs = get_post_meta($post_id, '_wp_old_slug'); 
     2100        $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); 
    21012101 
    21022102        // if we haven't added this old slug before, add it now 
  • trunk/wp-admin/export.php

    r816 r817  
    5151 
    5252header('Content-Description: File Transfer'); 
    53 header('Content-Type: application/octet-stream'); 
    5453header("Content-Disposition: attachment; filename=$filename"); 
    55 header('Content-type: text/wxr+xml; charset=' . get_option('blog_charset'), true); 
     54header('Content-type: text/xml; charset=' . get_option('blog_charset'), true); 
    5655 
    5756$where = ''; 
     
    128127<!-- It contains information about your blog's posts, comments, and categories. --> 
    129128<!-- You may use this file to transfer that content from one site to another. --> 
    130 <!-- To import this information into a WordPress blog, --> 
    131 <!-- 1. Log into that blog as an administrator --> 
    132 <!-- 2. Go to Manage: Import in the blog's admin panels --> 
    133 <!-- 3. Choose "WordPress" from the list --> 
    134 <!-- 4. Upload this file using the form provided on that page --> 
    135 <!-- You will be taken through the simple import procedure. --> 
     129<!-- This file is not intended to serve as a complete backup of your blog. --> 
     130 
     131<!-- To import this information into a WordPress blog follow these steps. --> 
     132<!-- 1. Log into that blog as an administrator. --> 
     133<!-- 2. Go to Manage: Import in the blog's admin panels. --> 
     134<!-- 3. Choose "WordPress" from the list. --> 
     135<!-- 4. Upload this file using the form provided on that page. --> 
     136<!-- 5. You will first be asked to map the authors in this export file to users --> 
     137<!--    on the blog.  For each author, you may choose to map to an --> 
     138<!--    existing user on the blog or to create a new user --> 
     139<!-- 6. WordPress will then import each of the posts, comments, and categories --> 
     140<!--    contained in this file into your blog --> 
    136141 
    137142<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"--> 
  • trunk/wp-admin/upgrade-schema.php

    r810 r817  
    290290        // 2.0 
    291291        add_option('default_role', 'subscriber'); 
    292         add_option('rich_editing', 'true'); 
    293292        add_option('db_version', $wp_db_version); 
    294293        // 2.0.1 
     
    311310 
    312311        // Delete unused options 
    313         $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action'); 
     312        $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing'); 
    314313        foreach ($unusedoptions as $option) : 
    315314                delete_option($option); 
  • trunk/wp-content/themes/default/archive.php

    r734 r817  
    77                 <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> 
    88<?php /* If this is a category archive */ if (is_category()) { ?> 
    9                 <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2> 
     9                <h2 class="pagetitle">Archive for the &#8216;<?php echo single_cat_title(); ?>&#8217; Category</h2> 
    1010 
    1111          <?php /* If this is a daily archive */ } elseif (is_day()) { ?> 
     
    4141                                </div> 
    4242 
    43                                 <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>  
     43                                <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> 
    4444 
    4545                        </div> 
  • trunk/wp-content/themes/default/style.css

    r731 r817  
    187187        } 
    188188 
    189 #wp-calendar #prev a
     189#wp-calendar #prev a, #wp-calendar #next a
    190190        font-size: 9pt; 
    191191        } 
     
    252252        margin: 0 0 40px; 
    253253        text-align: justify; 
     254        } 
     255 
     256.post hr { 
     257        display: block; 
    254258        } 
    255259 
  • trunk/wp-includes/classes.php

    r810 r817  
    431431                                        $cb_args = array_merge( array($output, $depth - 1), $args); 
    432432                                        $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args); 
     433                                } else {  // If we've reached depth, end the previous element. 
     434                                        $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args); 
     435                                        $output = call_user_func_array(array(&$this, 'end_el'), $cb_args); 
    433436                                } 
    434437                        } else if ( $element->$parent_field == $previous_element->$parent_field) { 
     
    501504 
    502505                $css_class = 'page_item'; 
     506                $_current_page = get_page( $current_page ); 
    503507                if ( $page->ID == $current_page ) 
    504508                        $css_class .= ' current_page_item'; 
     509                elseif ( $_current_page && $page->ID == $_current_page->post_parent ) 
     510                        $css_class .= ' current_page_parent'; 
    505511 
    506512                $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . wp_specialchars($page->post_title, 1) . '">' . $page->post_title . '</a>'; 
     
    610616                        $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); 
    611617                } 
    612          
     618 
     619                $_current_category = get_category( $current_category ); 
     620 
    613621                if ( 'list' == $args['style'] ) { 
    614622                        $output .= "\t<li"; 
    615623                        if ( ($category->cat_ID == $current_category) && is_category() ) 
    616624                                $output .=  ' class="current-cat"'; 
     625                        elseif ( ($category->cat_ID == $_current_category->category_parent) && is_category() ) 
     626                                $output .=  ' class="current-cat-parent"'; 
    617627                        $output .= ">$link\n"; 
    618628                } else { 
  • trunk/wp-includes/comment-template.php

    r810 r817  
    291291        } 
    292292 
     293        $comments = apply_filters( 'comments_array', $comments, $post->ID ); 
     294 
    293295        define('COMMENTS_TEMPLATE', true); 
    294296        $include = apply_filters('comments_template', TEMPLATEPATH . $file ); 
  • trunk/wp-includes/formatting.php

    r816 r817  
    3333                        // regular expressions 
    3434                        $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); 
    35                 } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) { 
     35                } elseif ( strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd') || strstr($curl, '<style') || strstr($curl, '<script') ) {  
    3636                        $next = false; 
    3737                } else { 
     
    5757        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 
    5858        // Space things out a little 
    59         $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|input|param|script)[^>]*>)!', "\n$1", $pee); 
    60         $pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|input|param|script)>)!', "$1\n\n", $pee); 
     59        $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])'; 
     60        $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); 
     61        $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee); 
    6162        $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines 
    6263        $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates 
    6364        $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end 
    6465        $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace 
    65         $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag 
     66        $pee = preg_replace( '|<p>(<div[^>]*>\s*)|', "$1<p>", $pee ); 
     67        $pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee); 
     68        $pee = preg_replace( '|<p>|', "$1<p>", $pee ); 
     69        $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag 
    6670        $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists 
    6771        $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee); 
    6872        $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); 
    69         $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee); 
    70         $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); 
     73        $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee); 
     74        $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); 
    7175        if ($br) { 
    7276                $pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee); 
     
    7478                $pee = str_replace('<WPPreserveNewline />', "\n", $pee); 
    7579        } 
    76         $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee); 
     80        $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee); 
    7781        $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); 
    78         $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' ", $pee); 
    79  
     82        if ( strstr( $pee, '<pre' ) ) 
     83                $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' ", $pee); 
     84        $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); 
     85/**/ 
    8086        return $pee; 
    8187} 
     
    117123} 
    118124 
    119 function utf8_uri_encode( $utf8_string ) { 
     125function utf8_uri_encode( $utf8_string, $length = 0 ) { 
    120126        $unicode = ''; 
    121127        $values = array(); 
     
    127133 
    128134                if ( $value < 128 ) { 
     135                        if ( $length && ( strlen($unicode) + 1 > $length ) ) 
     136                                break;  
    129137                        $unicode .= chr($value); 
    130138                } else { 
     
    133141                        $values[] = $value; 
    134142 
     143                        if ( $length && ( (strlen($unicode) + ($num_octets * 3)) > $length ) ) 
     144                                break; 
    135145                        if ( count( $values ) == $num_octets ) { 
    136         if ($num_octets == 3) { 
    137                 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); 
    138         } else { 
    139                 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); 
    140        
    141  
    142         $values = array(); 
    143         $num_octets = 1; 
     146                               if ($num_octets == 3) { 
     147                                       $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); 
     148                               } else { 
     149                                       $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); 
     150                               
     151 
     152                               $values = array(); 
     153                               $num_octets = 1; 
    144154                        } 
    145155                } 
     
    329339                        $title = mb_strtolower($title, 'UTF-8'); 
    330340                } 
    331                 $title = utf8_uri_encode($title); 
     341                $title = utf8_uri_encode($title, 200); 
    332342        } 
    333343 
  • trunk/wp-includes/post.php

    r811 r817  
    12491249        else 
    12501250                $post_name = sanitize_title($post_name); 
     1251 
     1252        $post_name_check = 
     1253                $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'inherit' AND ID != '$post_ID' LIMIT 1"); 
     1254 
     1255        if ($post_name_check) { 
     1256                $suffix = 2; 
     1257                while ($post_name_check) { 
     1258                        $alt_post_name = $post_name . "-$suffix"; 
     1259                        $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'inherit' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1"); 
     1260                        $suffix++; 
     1261                } 
     1262                $post_name = $alt_post_name; 
     1263        } 
    12511264 
    12521265        if (empty($post_date)) 
  • trunk/wp-includes/query.php

    r816 r817  
    972972                $distinct = apply_filters('posts_distinct', $distinct); 
    973973                $fields = apply_filters('posts_fields', "$wpdb->posts.*"); 
     974                $limits = apply_filters( 'post_limits', $limits ); 
    974975                $found_rows = ''; 
    975976                if ( !empty($limits) ) 
    976977                        $found_rows = 'SQL_CALC_FOUND_ROWS'; 
     978 
    977979                $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits"; 
    978980                $this->request = apply_filters('posts_request', $request); 
     
    980982                $this->posts = $wpdb->get_results($this->request); 
    981983                if ( !empty($limits) ) { 
    982                         $this->found_posts = $wpdb->get_var('SELECT FOUND_ROWS()'); 
     984                        $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 
     985                        $this->found_posts = $wpdb->get_var( $found_posts_query ); 
     986                        $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); 
    983987                        $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 
    984988                } 
  • trunk/xmlrpc.php

    r812 r817  
    406406            return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.'); 
    407407          } 
     408          $this->attach_uploads( $post_ID, $post_content ); 
    408409 
    409410          logIO('O', "Posted ! ID: $post_ID"); 
     
    455456                return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be edited.'); 
    456457          } 
     458          $this->attach_uploads( $ID, $post_content ); 
    457459 
    458460          return true; 
     
    575577          } 
    576578 
     579          $this->attach_uploads( $post_ID, $post_content ); 
     580 
    577581          logIO('O', "Posted ! ID: $post_ID"); 
    578582 
     
    580584        } 
    581585 
     586        function attach_uploads( $post_ID, $post_content ) { 
     587                global $wpdb; 
     588 
     589                // find any unattached files 
     590                $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '-1' AND post_type = 'attachment'" ); 
     591                if( is_array( $attachments ) ) { 
     592                        foreach( $attachments as $file ) { 
     593                                if( strpos( $post_content, $file->guid ) !== false ) { 
     594                                        $wpdb->query( "UPDATE {$wpdb->posts} SET post_parent = '$post_ID' WHERE ID = '{$file->ID}'" ); 
     595                                } 
     596                        } 
     597                } 
     598        } 
    582599 
    583600        /* metaweblog.editPost ...edits a post */ 
     
    654671            return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.'); 
    655672          } 
     673          $this->attach_uploads( $ID, $post_content ); 
    656674 
    657675          logIO('O',"(MW) Edited ! ID: $post_ID"); 
     
    852870                        return new IXR_Error(500, 'Could not write file '.$name); 
    853871                } 
     872                // Construct the attachment array 
     873                // attach to post_id -1 
     874                $post_id = -1; 
     875                $attachment = array( 
     876                        'post_title' => $name, 
     877                        'post_content' => '', 
     878                        'post_type' => 'attachment', 
     879                        'post_parent' => $post_id, 
     880                        'post_mime_type' => $type, 
     881                        'guid' => $upload[ 'url' ] 
     882                ); 
     883                // Save the data 
     884                $id = wp_insert_attachment($attachment, $upload[ 'file' ], $post_id); 
     885                add_post_meta($id, '_wp_attachment_metadata', array()); 
     886 
    854887                return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) ); 
    855888        }