Changeset 810

Show
Ignore:
Timestamp:
11/24/06 16:16:44 (2 years ago)
Author:
donncha
Message:

WP Merge to 4524

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/index.php

    r591 r810  
    1 <?php  
     1<?php 
    22/* Short and sweet */ 
    33define('WP_USE_THEMES', true); 
  • trunk/wp-admin/admin-ajax.php

    r753 r810  
    129129case 'add-cat' : // From Manage->Categories 
    130130        if ( !current_user_can( 'manage_categories' ) ) 
    131                 die('-1'); 
     131               die('-1'); 
    132132        if ( !$cat = wp_insert_category( $_POST ) ) 
    133133                die('0'); 
  • trunk/wp-admin/admin-db.php

    r798 r810  
    4949                if ( $user->has_cap('edit_posts') || $exclude_zeros == false ) 
    5050                        return array($user->id); 
    51                 else  
     51                else 
    5252                        return false; 
    5353        } 
     
    157157 
    158158        $cat_ID = (int) $catarr['cat_ID']; 
     159 
     160        if( $cat_ID == $catarr['category_parent'] ) 
     161                return false; 
    159162 
    160163        // First, get all of the original fields 
     
    202205                else 
    203206                        $cats = array_diff($cats, array($cat_ID)); 
    204                 wp_set_post_categories($post_id, $cats);  
     207                wp_set_post_categories($post_id, $cats); 
    205208        } 
    206209 
     
    213216                else 
    214217                        $cats = array_diff($cats, array($cat_ID)); 
    215                 wp_set_link_cats($link_id, $cats);  
    216         } 
    217          
     218                wp_set_link_cats($link_id, $cats); 
     219        } 
     220 
    218221        wp_cache_delete($cat_ID, 'category'); 
    219222        wp_cache_delete('all_category_ids', 'category'); 
     
    288291function wp_revoke_user($id) { 
    289292        $id = (int) $id; 
    290          
     293 
    291294        $user = new WP_User($id); 
    292         $user->remove_all_caps();       
     295        $user->remove_all_caps(); 
    293296} 
    294297 
     
    388391 
    389392        // Passed link category list overwrites existing category list if not empty. 
    390       if ( isset($linkdata['link_category']) && is_array($linkdata['link_category']) 
     393      if ( isset($linkdata['link_category']) && is_array($linkdata['link_category']) 
    391394                         && 0 != count($linkdata['link_category']) ) 
    392               $link_cats = $linkdata['link_category']; 
    393         else  
    394               $link_cats = $link['link_category']; 
     395              $link_cats = $linkdata['link_category']; 
     396        else 
     397              $link_cats = $link['link_category']; 
    395398 
    396399        // Merge old and new fields with new fields overwriting old ones. 
    397400        $linkdata = array_merge($link, $linkdata); 
    398       $linkdata['link_category'] = $link_cats; 
     401      $linkdata['link_category'] = $link_cats; 
    399402 
    400403        return wp_insert_link($linkdata); 
     
    405408 
    406409        do_action('delete_link', $link_id); 
    407          
     410 
    408411        $categories = wp_get_link_cats($link_id); 
    409412        if( is_array( $categories ) ) { 
     
    421424        global $wpdb; 
    422425 
    423         $sql = "SELECT category_id  
    424                 FROM $wpdb->link2cat  
    425                 WHERE link_id = $link_ID  
     426        $sql = "SELECT category_id 
     427                FROM $wpdb->link2cat 
     428                WHERE link_id = $link_ID 
    426429                ORDER BY category_id"; 
    427430 
     
    444447        // First the old categories 
    445448        $old_categories = $wpdb->get_col(" 
    446                 SELECT category_id  
    447                 FROM $wpdb->link2cat  
     449                SELECT category_id 
     450                FROM $wpdb->link2cat 
    448451                WHERE link_id = $link_ID"); 
    449452 
     
    460463                foreach ($delete_cats as $del) { 
    461464                        $wpdb->query(" 
    462                                 DELETE FROM $wpdb->link2cat  
    463                                 WHERE category_id = $del  
    464                                         AND link_id = $link_ID  
     465                                DELETE FROM $wpdb->link2cat 
     466                                WHERE category_id = $del 
     467                                        AND link_id = $link_ID 
    465468                                "); 
    466469                } 
     
    473476                foreach ($add_cats as $new_cat) { 
    474477                        $wpdb->query(" 
    475                                 INSERT INTO $wpdb->link2cat (link_id, category_id)  
     478                                INSERT INTO $wpdb->link2cat (link_id, category_id) 
    476479                                VALUES ($link_ID, $new_cat)"); 
    477480                } 
    478481        } 
    479          
     482 
    480483        // Update category counts. 
    481484        $all_affected_cats = array_unique(array_merge($link_categories, $old_categories)); 
     
    484487                $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'"); 
    485488                wp_cache_delete($cat_id, 'category'); 
    486         } 
     489                do_action('edit_category', $cat_id); 
     490        } 
     491 
     492        do_action('edit_link', $link_ID); 
    487493}       // wp_set_link_cats() 
    488494 
  • trunk/wp-admin/admin-functions.php

    r804 r810  
    33function write_post() { 
    44        $result = wp_write_post(); 
    5         if( is_wp_error($result) ) 
     5        if( is_wp_error( $result ) ) 
    66                wp_die( $result->get_error_message() ); 
    77        else 
     
    1414 
    1515        if ( 'page' == $_POST['post_type'] ) { 
    16                 if ( !current_user_can('edit_pages') ) 
    17                         return new WP_Error('edit_pages', __('You are not allowed to create pages on this blog.')); 
    18         } else { 
    19                 if ( !current_user_can('edit_posts') ) 
    20                         return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this blog.')); 
     16                if ( !current_user_can( 'edit_pages' ) ) 
     17                        return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) ); 
     18        } else { 
     19                if ( !current_user_can( 'edit_posts' ) ) 
     20                        return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) ); 
    2121        } 
    2222 
     
    2727        $_POST['to_ping'] = $_POST['trackback_url']; 
    2828 
    29         if (!empty ($_POST['post_author_override'])) { 
     29        if (!empty ( $_POST['post_author_override'] ) ) { 
    3030                $_POST['post_author'] = (int) $_POST['post_author_override']; 
    3131        } else { 
    32                 if (!empty ($_POST['post_author'])) { 
     32                if (!empty ( $_POST['post_author'] ) ) { 
    3333                        $_POST['post_author'] = (int) $_POST['post_author']; 
    3434                } else { 
     
    3838        } 
    3939 
    40         if ($_POST['post_author'] != $_POST['user_ID']) { 
     40        if ( $_POST['post_author'] != $_POST['user_ID'] ) { 
    4141                if ( 'page' == $_POST['post_type'] ) { 
    42                         if ( !current_user_can('edit_others_pages') ) 
    43                                 return new WP_Error('edit_others_pages', __('You cannot create pages as this user.')); 
     42                        if ( !current_user_can( 'edit_others_pages' ) ) 
     43                                return new WP_Error( 'edit_others_pages', __( 'You cannot create pages as this user.' ) ); 
    4444                } else { 
    45                         if ( !current_user_can('edit_others_posts') ) 
    46                                 return new WP_Error('edit_others_posts', __('You cannot post as this user.')); 
     45                        if ( !current_user_can( 'edit_others_posts' ) ) 
     46                                return new WP_Error( 'edit_others_posts', __( 'You cannot post as this user.' ) ); 
    4747 
    4848                } 
     
    5050 
    5151        // What to do based on which button they pressed 
    52         if ('' != $_POST['saveasdraft']
     52        if ('' != $_POST['saveasdraft']
    5353                $_POST['post_status'] = 'draft'; 
    54         if ('' != $_POST['saveasprivate']
     54        if ('' != $_POST['saveasprivate']
    5555                $_POST['post_status'] = 'private'; 
    56         if ('' != $_POST['publish']
     56        if ('' != $_POST['publish']
    5757                $_POST['post_status'] = 'publish'; 
    58         if ('' != $_POST['advanced']
     58        if ('' != $_POST['advanced']
    5959                $_POST['post_status'] = 'draft'; 
    6060 
    6161        if ( 'page' == $_POST['post_type'] ) { 
    62                 if ('publish' == $_POST['post_status'] && !current_user_can('publish_pages')
     62                if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' )
    6363                        $_POST['post_status'] = 'draft'; 
    6464        } else { 
    65                 if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')
     65                if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' )
    6666                        $_POST['post_status'] = 'draft'; 
    6767        } 
    6868 
    69         if (!isset ($_POST['comment_status'])) 
     69        if (!isset( $_POST['comment_status'] )) 
    7070                $_POST['comment_status'] = 'closed'; 
    7171 
    72         if (!isset ($_POST['ping_status'])) 
     72        if (!isset( $_POST['ping_status'] )) 
    7373                $_POST['ping_status'] = 'closed'; 
    7474 
    75         if (!empty ($_POST['edit_date'])) { 
     75        if (!empty ( $_POST['edit_date'] ) ) { 
    7676                $aa = $_POST['aa']; 
    7777                $mm = $_POST['mm']; 
     
    8080                $mn = $_POST['mn']; 
    8181                $ss = $_POST['ss']; 
    82                 $jj = ($jj > 31) ? 31 : $jj; 
    83                 $hh = ($hh > 23) ? $hh -24 : $hh; 
    84                 $mn = ($mn > 59) ? $mn -60 : $mn; 
    85                 $ss = ($ss > 59) ? $ss -60 : $ss; 
    86                 $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss); 
    87                 $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']); 
     82                $jj = ($jj > 31 ) ? 31 : $jj; 
     83                $hh = ($hh > 23 ) ? $hh -24 : $hh; 
     84                $mn = ($mn > 59 ) ? $mn -60 : $mn; 
     85                $ss = ($ss > 59 ) ? $ss -60 : $ss; 
     86                $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 
     87                $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] ); 
    8888        } 
    8989 
    9090        // Create the post. 
    91         $post_ID = wp_insert_post($_POST); 
    92         add_meta($post_ID); 
     91        $post_ID = wp_insert_post( $_POST); 
     92        add_meta( $post_ID ); 
    9393 
    9494        // Reunite any orphaned attachments with their parent 
    9595        if ( $_POST['temp_ID'] ) 
    96                 relocate_children($_POST['temp_ID'], $post_ID); 
     96                relocate_children( $_POST['temp_ID'], $post_ID ); 
    9797 
    9898        // Now that we have an ID we can fix any attachment anchor hrefs 
    99         fix_attachment_links($post_ID); 
     99        fix_attachment_links( $post_ID ); 
    100100 
    101101        return $post_ID; 
     
    103103 
    104104// Move child posts to a new parent 
    105 function relocate_children($old_ID, $new_ID) { 
     105function relocate_children( $old_ID, $new_ID ) { 
    106106        global $wpdb; 
    107107        $old_ID = (int) $old_ID; 
    108108        $new_ID = (int) $new_ID; 
    109         return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID"); 
     109        return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); 
    110110} 
    111111 
    112112// Replace hrefs of attachment anchors with up-to-date permalinks. 
    113 function fix_attachment_links($post_ID) { 
     113function fix_attachment_links( $post_ID ) { 
    114114        global $wp_rewrite; 
    115115 
    116         $post = & get_post($post_ID, ARRAY_A); 
    117  
    118         $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie"; 
     116        $post = & get_post( $post_ID, ARRAY_A ); 
     117 
     118        $search = "#<a[^>]+rel=('|\" )[^'\"]*attachment[^>]*>#ie"; 
    119119 
    120120        // See if we have any rel="attachment" links 
    121         if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) ) 
     121        if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) ) 
    122122                return; 
    123123 
    124124        $i = 0; 
    125         $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i"; 
     125        $search = "#[\s]+rel=(\"|' )(.*? )wp-att-(\d+ )\\1#i"; 
    126126        foreach ( $anchor_matches[0] as $anchor ) { 
    127                 if ( 0 == preg_match($search, $anchor, $id_matches) ) 
     127                if ( 0 == preg_match( $search, $anchor, $id_matches ) ) 
    128128                        continue; 
    129129 
     
    131131 
    132132                // While we have the attachment ID, let's adopt any orphans. 
    133                 $attachment = & get_post($id, ARRAY_A); 
    134                 if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) { 
     133                $attachment = & get_post( $id, ARRAY_A ); 
     134                if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) { 
    135135                        $attachment['post_parent'] = $post_ID; 
    136136                        // Escape data pulled from DB. 
    137                         $attachment = add_magic_quotes($attachment); 
    138                         wp_update_post($attachment); 
     137                        $attachment = add_magic_quotes( $attachment); 
     138                        wp_update_post( $attachment); 
    139139                } 
    140140 
    141141                $post_search[$i] = $anchor; 
    142                 $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor); 
     142                $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor ); 
    143143                ++$i; 
    144144        } 
    145145 
    146         $post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']); 
     146        $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] ); 
    147147 
    148148        // Escape data pulled from DB. 
    149         $post = add_magic_quotes($post); 
    150  
    151         return wp_update_post($post); 
     149        $post = add_magic_quotes( $post); 
     150 
     151        return wp_update_post( $post); 
    152152} 
    153153 
     
    159159 
    160160        if ( 'page' == $_POST['post_type'] ) { 
    161                 if ( !current_user_can('edit_page', $post_ID) ) 
    162                         wp_die(__('You are not allowed to edit this page.')); 
    163         } else { 
    164                 if ( !current_user_can('edit_post', $post_ID) ) 
    165                         wp_die(__('You are not allowed to edit this post.')); 
     161                if ( !current_user_can( 'edit_page', $post_ID ) ) 
     162                        wp_die( __('You are not allowed to edit this page.' )); 
     163        } else { 
     164                if ( !current_user_can( 'edit_post', $post_ID ) ) 
     165                        wp_die( __('You are not allowed to edit this post.' )); 
    166166        } 
    167167 
     
    173173        $_POST['to_ping'] = $_POST['trackback_url']; 
    174174 
    175         if (!empty ($_POST['post_author_override'])) { 
     175        if (!empty ( $_POST['post_author_override'] ) ) { 
    176176                $_POST['post_author'] = (int) $_POST['post_author_override']; 
    177177        } else 
    178                 if (!empty ($_POST['post_author'])) { 
     178                if (!empty ( $_POST['post_author'] ) ) { 
    179179                        $_POST['post_author'] = (int) $_POST['post_author']; 
    180180                } else { 
     
    182182                } 
    183183 
    184         if ($_POST['post_author'] != $_POST['user_ID']) { 
     184        if ( $_POST['post_author'] != $_POST['user_ID'] ) { 
    185185                if ( 'page' == $_POST['post_type'] ) { 
    186                         if ( !current_user_can('edit_others_pages') ) 
    187                                 wp_die(__('You cannot edit pages as this user.')); 
     186                        if ( !current_user_can( 'edit_others_pages' ) ) 
     187                                wp_die( __('You cannot edit pages as this user.' )); 
    188188                } else { 
    189                         if ( !current_user_can('edit_others_posts') ) 
    190                                 wp_die(__('You cannot edit posts as this user.')); 
     189                        if ( !current_user_can( 'edit_others_posts' ) ) 
     190                                wp_die( __('You cannot edit posts as this user.' )); 
    191191 
    192192                } 
     
    194194 
    195195        // What to do based on which button they pressed 
    196         if ('' != $_POST['saveasdraft']
     196        if ('' != $_POST['saveasdraft']
    197197                $_POST['post_status'] = 'draft'; 
    198         if ('' != $_POST['saveasprivate']
     198        if ('' != $_POST['saveasprivate']
    199199                $_POST['post_status'] = 'private'; 
    200         if ('' != $_POST['publish']
     200        if ('' != $_POST['publish']
    201201                $_POST['post_status'] = 'publish'; 
    202         if ('' != $_POST['advanced']
     202        if ('' != $_POST['advanced']
    203203                $_POST['post_status'] = 'draft'; 
    204204 
    205205        if ( 'page' == $_POST['post_type'] ) { 
    206                 if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_pages')) 
     206                if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) 
    207207                        $_POST['post_status'] = 'draft'; 
    208208        } else { 
    209                 if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_posts')) 
     209                if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) 
    210210                        $_POST['post_status'] = 'draft'; 
    211211        } 
    212212 
    213         if (!isset ($_POST['comment_status'])) 
     213        if (!isset( $_POST['comment_status'] )) 
    214214                $_POST['comment_status'] = 'closed'; 
    215215 
    216         if (!isset ($_POST['ping_status'])) 
     216        if (!isset( $_POST['ping_status'] )) 
    217217                $_POST['ping_status'] = 'closed'; 
    218218 
    219         if (!empty ($_POST['edit_date'])) { 
     219        if (!empty ( $_POST['edit_date'] ) ) { 
    220220                $aa = $_POST['aa']; 
    221221                $mm = $_POST['mm']; 
     
    224224                $mn = $_POST['mn']; 
    225225                $ss = $_POST['ss']; 
    226                 $jj = ($jj > 31) ? 31 : $jj; 
    227                 $hh = ($hh > 23) ? $hh -24 : $hh; 
    228                 $mn = ($mn > 59) ? $mn -60 : $mn; 
    229                 $ss = ($ss > 59) ? $ss -60 : $ss; 
     226                $jj = ($jj > 31 ) ? 31 : $jj; 
     227                $hh = ($hh > 23 ) ? $hh -24 : $hh; 
     228                $mn = ($mn > 59 ) ? $mn -60 : $mn; 
     229                $ss = ($ss > 59 ) ? $ss -60 : $ss; 
    230230                $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 
    231                 $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); 
     231                $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" ); 
    232232        } 
    233233 
    234234        // Meta Stuff 
    235         if ($_POST['meta']) { 
    236                 foreach ($_POST['meta'] as $key => $value
    237                         update_meta($key, $value['key'], $value['value']); 
    238         } 
    239  
    240         if ($_POST['deletemeta']) { 
    241                 foreach ($_POST['deletemeta'] as $key => $value
    242                         delete_meta($key); 
    243         } 
    244  
    245         add_meta($post_ID); 
    246  
    247         wp_update_post($_POST); 
     235        if ( $_POST['meta'] ) { 
     236                foreach ( $_POST['meta'] as $key => $value
     237                        update_meta( $key, $value['key'], $value['value'] ); 
     238        } 
     239 
     240        if ( $_POST['deletemeta'] ) { 
     241                foreach ( $_POST['deletemeta'] as $key => $value
     242                        delete_meta( $key ); 
     243        } 
     244 
     245        add_meta( $post_ID ); 
     246 
     247        wp_update_post( $_POST); 
    248248 
    249249        // Now that we have an ID we can fix any attachment anchor hrefs 
    250         fix_attachment_links($post_ID); 
     250        fix_attachment_links( $post_ID ); 
    251251 
    252252        return $post_ID; 
     
    259259        $comment_post_ID = (int) $_POST['comment_post_ID']; 
    260260 
    261         if (!current_user_can('edit_post', $comment_post_ID)) 
    262                 wp_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.')); 
     261        if (!current_user_can( 'edit_post', $comment_post_ID )) 
     262                wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' )); 
    263263 
    264264        $_POST['comment_author'] = $_POST['newcomment_author']; 
     
    269269        $_POST['comment_ID'] = (int) $_POST['comment_ID']; 
    270270 
    271         if (!empty ($_POST['edit_date'])) { 
     271        if (!empty ( $_POST['edit_date'] ) ) { 
    272272                $aa = $_POST['aa']; 
    273273                $mm = $_POST['mm']; 
     
    276276                $mn = $_POST['mn']; 
    277277                $ss = $_POST['ss']; 
    278                 $jj = ($jj > 31) ? 31 : $jj; 
    279                 $hh = ($hh > 23) ? $hh -24 : $hh; 
    280                 $mn = ($mn > 59) ? $mn -60 : $mn; 
    281                 $ss = ($ss > 59) ? $ss -60 : $ss; 
     278                $jj = ($jj > 31 ) ? 31 : $jj; 
     279                $hh = ($hh > 23 ) ? $hh -24 : $hh; 
     280                $mn = ($mn > 59 ) ? $mn -60 : $mn; 
     281                $ss = ($ss > 59 ) ? $ss -60 : $ss; 
    282282                $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 
    283283        } 
    284284 
    285         wp_update_comment($_POST); 
     285        wp_update_comment( $_POST); 
    286286} 
    287287 
    288288// Get an existing post and format it for editing. 
    289 function get_post_to_edit($id) { 
    290  
    291         $post = get_post($id); 
    292  
    293         $post->post_content = format_to_edit($post->post_content, user_can_richedit()); 
    294         $post->post_content = apply_filters('content_edit_pre', $post->post_content); 
    295  
    296         $post->post_excerpt = format_to_edit($post->post_excerpt); 
    297         $post->post_excerpt = apply_filters('excerpt_edit_pre', $post->post_excerpt); 
    298  
    299         $post->post_title = format_to_edit($post->post_title); 
    300         $post->post_title = apply_filters('title_edit_pre', $post->post_title); 
    301  
    302         $post->post_password = format_to_edit($post->post_password); 
    303  
    304         if ($post->post_type == 'page'
    305                 $post->page_template = get_post_meta($id, '_wp_page_template', true); 
     289function get_post_to_edit( $id ) { 
     290 
     291        $post = get_post( $id ); 
     292 
     293        $post->post_content = format_to_edit( $post->post_content, user_can_richedit() ); 
     294        $post->post_content = apply_filters( 'content_edit_pre', $post->post_content); 
     295 
     296        $post->post_excerpt = format_to_edit( $post->post_excerpt); 
     297        $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt); 
     298 
     299        $post->post_title = format_to_edit( $post->post_title ); 
     300        $post->post_title = apply_filters( 'title_edit_pre', $post->post_title ); 
     301 
     302        $post->post_password = format_to_edit( $post->post_password ); 
     303 
     304        if ( $post->post_type == 'page'
     305                $post->page_template = get_post_meta( $id, '_wp_page_template', true ); 
    306306 
    307307        return $post; 
     
    310310// Default post information to use when populating the "Write Post" form. 
    311311function get_default_post_to_edit() { 
    312         if ( !empty($_REQUEST['post_title']) ) 
    313                 $post_title = wp_specialchars(stripslashes($_REQUEST['post_title'])); 
    314         else if ( !empty($_REQUEST['popuptitle']) ) { 
    315                 $post_title = wp_specialchars(stripslashes($_REQUEST['popuptitle'])); 
    316                 $post_title = funky_javascript_fix($post_title); 
     312        if ( !empty( $_REQUEST['post_title'] ) ) 
     313                $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] )); 
     314        else if ( !empty( $_REQUEST['popuptitle'] ) ) { 
     315                $post_title = wp_specialchars( stripslashes( $_REQUEST