Changeset 1069

Show
Ignore:
Timestamp:
10/12/07 16:21:15 (9 months ago)
Author:
donncha
Message:

Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439

Files:

Legend:

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

    r1062 r1069  
    410410        ?><h2>Installation Finished!</h2> 
    411411        <p>Congratulations! Your <a href='http://<?php echo $domain . $base; ?>'>WordPress &micro; site</a> has been configured.</p> 
    412         <p>You can <a href='wp-login.php'>log in</a> using the username "admin" and password "<?php echo $pass; ?>"</p> 
     412        <p>You can <a href='wp-login.php'>log in</a> using the username "admin" and password <?php echo $pass; ?></p> 
    413413        <h3>Directory Permissions</h3> 
    414414        <p>Please remember to reset the permissions on the following directories:<ul> 
     
    470470                // Install Blog! 
    471471                include_once('./wp-config.php'); 
    472                 include_once('./wp-admin/upgrade-functions.php'); 
     472                include_once('./wp-admin/includes/upgrade.php'); 
    473473                // normalise hostname - no www. 
    474474                $_SERVER[ 'HTTP_HOST' ] = str_replace( 'www.', '', $_SERVER[ 'HTTP_HOST' ] ); 
  • trunk/wp-admin/admin-ajax.php

    r1051 r1069  
    11<?php 
    22require_once('../wp-config.php'); 
    3 require_once('admin-functions.php'); 
    4 require_once('admin-db.php'); 
     3require_once('includes/admin.php'); 
    54 
    65define('DOING_AJAX', true); 
     
    127126        $x->send(); 
    128127        break; 
     128case 'add-link-category' : // On the Fly 
     129        if ( !current_user_can( 'manage_categories' ) ) 
     130                die('-1'); 
     131        $names = explode(',', $_POST['newcat']); 
     132        $x = new WP_Ajax_Response(); 
     133        foreach ( $names as $cat_name ) { 
     134                $cat_name = trim($cat_name); 
     135                if ( !$slug = sanitize_title($cat_name) ) 
     136                        die('0'); 
     137                if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { 
     138                        $cat_id = wp_insert_term( $cat_name, 'link_category' ); 
     139                        $cat_id = $cat_id['term_id']; 
     140                } 
     141                $cat_name = wp_specialchars(stripslashes($cat_name)); 
     142                $x->add( array( 
     143                        'what' => 'link-category', 
     144                        'id' => $cat_id, 
     145                        'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>" 
     146                ) ); 
     147        } 
     148        $x->send(); 
     149        break; 
    129150case 'add-cat' : // From Manage->Categories 
    130151        if ( !current_user_can( 'manage_categories' ) ) 
     
    184205                if ( $pid = wp_insert_post( array( 
    185206                        'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) 
    186                 ) ) ) 
     207                ) ) ) { 
     208                        if ( is_wp_error( $pid ) ) 
     209                                return $pid; 
    187210                        $mid = add_meta( $pid ); 
     211                } 
    188212                else 
    189213                        die('0'); 
  • trunk/wp-admin/admin-footer.php

    r1005 r1069  
    11 
    22<div id="footer"> 
    3 <p class="logo"><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p> 
    4 <p class="docs"><?php _e('<a href="http://codex.wordpress.org/">Documentation</a>'); ?> &#8212; <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br /> 
    5 <?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p> 
     3<p><?php 
     4 
     5$upgrade = apply_filters( 'update_footer', '' ); 
     6echo __('Thank you for creating with <a href="http://mu.wordpress.org/">WordPress MU</a>').' | '.__('<a href="http://codex.wordpress.org/">Documentation</a>') ?></p> 
    67</div> 
    78<?php do_action('admin_footer', ''); ?> 
  • trunk/wp-admin/admin-functions.php

    r1051 r1069  
    11<?php 
    2  
    3 function write_post() { 
    4         $result = wp_write_post(); 
    5         if( is_wp_error( $result ) ) 
    6                 wp_die( $result->get_error_message() ); 
    7         else 
    8                 return $result; 
    9 
    10  
    11 // Creates a new post from the "Write Post" form using $_POST information. 
    12 function wp_write_post() { 
    13         global $user_ID; 
    14  
    15         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.' ) ); 
    21         } 
    22  
    23  
    24         // Check for autosave collisions 
    25         $temp_id = false; 
    26         if ( isset($_POST['temp_ID']) ) { 
    27                 $temp_id = (int) $_POST['temp_ID']; 
    28                 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
    29                         $draft_ids = array(); 
    30                 foreach ( $draft_ids as $temp => $real ) 
    31                         if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then ) 
    32                                 unset($draft_ids[$temp]); 
    33  
    34                 if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write 
    35                         $_POST['post_ID'] = $draft_ids[$temp_id]; 
    36                         unset($_POST['temp_ID']); 
    37                         update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 
    38                         return edit_post(); 
    39                 } 
    40         } 
    41  
    42         // Rename. 
    43         $_POST['post_content'] = $_POST['content']; 
    44         $_POST['post_excerpt'] = $_POST['excerpt']; 
    45         $_POST['post_parent'] = $_POST['parent_id']; 
    46         $_POST['to_ping'] = $_POST['trackback_url']; 
    47  
    48         if (!empty ( $_POST['post_author_override'] ) ) { 
    49                 $_POST['post_author'] = (int) $_POST['post_author_override']; 
    50         } else { 
    51                 if (!empty ( $_POST['post_author'] ) ) { 
    52                         $_POST['post_author'] = (int) $_POST['post_author']; 
    53                 } else { 
    54                         $_POST['post_author'] = (int) $_POST['user_ID']; 
    55                 } 
    56  
    57         } 
    58  
    59         if ( $_POST['post_author'] != $_POST['user_ID'] ) { 
    60                 if ( 'page' == $_POST['post_type'] ) { 
    61                         if ( !current_user_can( 'edit_others_pages' ) ) 
    62                                 return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); 
    63                 } else { 
    64                         if ( !current_user_can( 'edit_others_posts' ) ) 
    65                                 return new WP_Error( 'edit_others_posts', __( 'You are not allowed to post as this user.' ) ); 
    66  
    67                 } 
    68         } 
    69  
    70         // What to do based on which button they pressed 
    71         if ('' != $_POST['saveasdraft'] ) 
    72                 $_POST['post_status'] = 'draft'; 
    73         if ('' != $_POST['saveasprivate'] ) 
    74                 $_POST['post_status'] = 'private'; 
    75         if ('' != $_POST['publish'] ) 
    76                 $_POST['post_status'] = 'publish'; 
    77         if ('' != $_POST['advanced'] ) 
    78                 $_POST['post_status'] = 'draft'; 
    79  
    80         if ( 'page' == $_POST['post_type'] ) { 
    81                 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) ) 
    82                         $_POST['post_status'] = 'draft'; 
    83         } else { 
    84                 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) ) 
    85                         $_POST['post_status'] = 'draft'; 
    86         } 
    87  
    88         if (!isset( $_POST['comment_status'] )) 
    89                 $_POST['comment_status'] = 'closed'; 
    90  
    91         if (!isset( $_POST['ping_status'] )) 
    92                 $_POST['ping_status'] = 'closed'; 
    93  
    94         if (!empty ( $_POST['edit_date'] ) ) { 
    95                 $aa = $_POST['aa']; 
    96                 $mm = $_POST['mm']; 
    97                 $jj = $_POST['jj']; 
    98                 $hh = $_POST['hh']; 
    99                 $mn = $_POST['mn']; 
    100                 $ss = $_POST['ss']; 
    101                 $jj = ($jj > 31 ) ? 31 : $jj; 
    102                 $hh = ($hh > 23 ) ? $hh -24 : $hh; 
    103                 $mn = ($mn > 59 ) ? $mn -60 : $mn; 
    104                 $ss = ($ss > 59 ) ? $ss -60 : $ss; 
    105                 $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 
    106                 $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] ); 
    107         } 
    108          
    109         unset($_POST['no_filter']); 
    110  
    111         // Create the post. 
    112         $post_ID = wp_insert_post( $_POST ); 
    113  
    114         add_meta( $post_ID ); 
    115  
    116         // Reunite any orphaned attachments with their parent 
    117         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
    118                 $draft_ids = array(); 
    119         if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 
    120                 relocate_children( $draft_temp_id, $post_ID ); 
    121         if ( $temp_id && $temp_id != $draft_temp_id ) 
    122                 relocate_children( $temp_id, $post_ID ); 
    123  
    124         // Update autosave collision detection 
    125         if ( $temp_id ) { 
    126                 $draft_ids[$temp_id] = $post_ID; 
    127                 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 
    128         } 
    129  
    130         // Now that we have an ID we can fix any attachment anchor hrefs 
    131         fix_attachment_links( $post_ID ); 
    132  
    133         return $post_ID; 
    134 
    135  
    136 // Move child posts to a new parent 
    137 function relocate_children( $old_ID, $new_ID ) { 
    138         global $wpdb; 
    139         $old_ID = (int) $old_ID; 
    140         $new_ID = (int) $new_ID; 
    141         return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); 
    142 
    143  
    144 // Replace hrefs of attachment anchors with up-to-date permalinks. 
    145 function fix_attachment_links( $post_ID ) { 
    146         global $wp_rewrite; 
    147  
    148         $post = & get_post( $post_ID, ARRAY_A ); 
    149  
    150         $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie"; 
    151  
    152         // See if we have any rel="attachment" links 
    153         if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) ) 
    154                 return; 
    155  
    156         $i = 0; 
    157         $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i"; 
    158         foreach ( $anchor_matches[0] as $anchor ) { 
    159                 if ( 0 == preg_match( $search, $anchor, $id_matches ) ) 
    160                         continue; 
    161  
    162                 $id = (int) $id_matches[3]; 
    163  
    164                 // While we have the attachment ID, let's adopt any orphans. 
    165                 $attachment = & get_post( $id, ARRAY_A ); 
    166                 if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) { 
    167                         $attachment['post_parent'] = $post_ID; 
    168                         // Escape data pulled from DB. 
    169                         $attachment = add_magic_quotes( $attachment); 
    170                         wp_update_post( $attachment); 
    171                 } 
    172  
    173                 $post_search[$i] = $anchor; 
    174                 $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor ); 
    175                 ++$i; 
    176         } 
    177  
    178         $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] ); 
    179  
    180         // Escape data pulled from DB. 
    181         $post = add_magic_quotes( $post); 
    182  
    183         return wp_update_post( $post); 
    184 
    185  
    186 // Update an existing post with values provided in $_POST. 
    187 function edit_post() { 
    188         global $user_ID; 
    189  
    190         $post_ID = (int) $_POST['post_ID']; 
    191  
    192         if ( 'page' == $_POST['post_type'] ) { 
    193                 if ( !current_user_can( 'edit_page', $post_ID ) ) 
    194                         wp_die( __('You are not allowed to edit this page.' )); 
    195         } else { 
    196                 if ( !current_user_can( 'edit_post', $post_ID ) ) 
    197                         wp_die( __('You are not allowed to edit this post.' )); 
    198         } 
    199  
    200         // Autosave shouldn't save too soon after a real save 
    201         if ( 'autosave' == $_POST['action'] ) { 
    202                 $post =& get_post( $post_ID ); 
    203                 $now = time(); 
    204                 $then = strtotime($post->post_date_gmt . ' +0000'); 
    205                 // Keep autosave_interval in sync with autosave-js.php. 
    206                 $delta = apply_filters( 'autosave_interval', 120 ) / 2; 
    207                 if ( ($now - $then) < $delta ) 
    208                         return $post_ID; 
    209         } 
    210  
    211         // Rename. 
    212         $_POST['ID'] = (int) $_POST['post_ID']; 
    213         $_POST['post_content'] = $_POST['content']; 
    214         $_POST['post_excerpt'] = $_POST['excerpt']; 
    215         $_POST['post_parent'] = $_POST['parent_id']; 
    216         $_POST['to_ping'] = $_POST['trackback_url']; 
    217  
    218         if (!empty ( $_POST['post_author_override'] ) ) { 
    219                 $_POST['post_author'] = (int) $_POST['post_author_override']; 
    220         } else 
    221                 if (!empty ( $_POST['post_author'] ) ) { 
    222                         $_POST['post_author'] = (int) $_POST['post_author']; 
    223                 } else { 
    224                         $_POST['post_author'] = (int) $_POST['user_ID']; 
    225                 } 
    226  
    227         if ( $_POST['post_author'] != $_POST['user_ID'] ) { 
    228                 if ( 'page' == $_POST['post_type'] ) { 
    229                         if ( !current_user_can( 'edit_others_pages' ) ) 
    230                                 wp_die( __('You are not allowed to edit pages as this user.' )); 
    231                 } else { 
    232                         if ( !current_user_can( 'edit_others_posts' ) ) 
    233                                 wp_die( __('You are not allowed to edit posts as this user.' )); 
    234  
    235                 } 
    236         } 
    237  
    238         // What to do based on which button they pressed 
    239         if ('' != $_POST['saveasdraft'] ) 
    240                 $_POST['post_status'] = 'draft'; 
    241         if ('' != $_POST['saveasprivate'] ) 
    242                 $_POST['post_status'] = 'private'; 
    243         if ('' != $_POST['publish'] ) 
    244                 $_POST['post_status'] = 'publish'; 
    245         if ('' != $_POST['advanced'] ) 
    246                 $_POST['post_status'] = 'draft'; 
    247  
    248         if ( 'page' == $_POST['post_type'] ) { 
    249                 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) 
    250                         $_POST['post_status'] = 'draft'; 
    251         } else { 
    252                 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) 
    253                         $_POST['post_status'] = 'draft'; 
    254         } 
    255  
    256         if (!isset( $_POST['comment_status'] )) 
    257                 $_POST['comment_status'] = 'closed'; 
    258  
    259         if (!isset( $_POST['ping_status'] )) 
    260                 $_POST['ping_status'] = 'closed'; 
    261  
    262         if (!empty ( $_POST['edit_date'] ) ) { 
    263                 $aa = $_POST['aa']; 
    264                 $mm = $_POST['mm']; 
    265                 $jj = $_POST['jj']; 
    266                 $hh = $_POST['hh']; 
    267                 $mn = $_POST['mn']; 
    268                 $ss = $_POST['ss']; 
    269                 $jj = ($jj > 31 ) ? 31 : $jj; 
    270                 $hh = ($hh > 23 ) ? $hh -24 : $hh; 
    271                 $mn = ($mn > 59 ) ? $mn -60 : $mn; 
    272                 $ss = ($ss > 59 ) ? $ss -60 : $ss; 
    273                 $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 
    274                 $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" ); 
    275         } 
    276  
    277         // Meta Stuff 
    278         if ( $_POST['meta'] ) { 
    279                 foreach ( $_POST['meta'] as $key => $value ) 
    280                         update_meta( $key, $value['key'], $value['value'] ); 
    281         } 
    282  
    283         if ( $_POST['deletemeta'] ) { 
    284                 foreach ( $_POST['deletemeta'] as $key => $value ) 
    285                         delete_meta( $key ); 
    286         } 
    287  
    288         unset($_POST['no_filter']); 
    289          
    290         add_meta( $post_ID ); 
    291  
    292         wp_update_post( $_POST ); 
    293  
    294         // Reunite any orphaned attachments with their parent 
    295         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
    296                 $draft_ids = array(); 
    297         if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 
    298                 relocate_children( $draft_temp_id, $post_ID ); 
    299  
    300         // Now that we have an ID we can fix any attachment anchor hrefs 
    301         fix_attachment_links( $post_ID ); 
    302  
    303         return $post_ID; 
    304 
    305  
    306 function edit_comment() { 
    307         global $user_ID; 
    308  
    309         $comment_ID = (int) $_POST['comment_ID']; 
    310         $comment_post_ID = (int) $_POST['comment_post_ID']; 
    311  
    312         if (!current_user_can( 'edit_post', $comment_post_ID )) 
    313                 wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' )); 
    314  
    315         $_POST['comment_author'] = $_POST['newcomment_author']; 
    316         $_POST['comment_author_email'] = $_POST['newcomment_author_email']; 
    317         $_POST['comment_author_url'] = $_POST['newcomment_author_url']; 
    318         $_POST['comment_approved'] = $_POST['comment_status']; 
    319         $_POST['comment_content'] = $_POST['content']; 
    320         $_POST['comment_ID'] = (int) $_POST['comment_ID']; 
    321  
    322         if (!empty ( $_POST['edit_date'] ) ) { 
    323                 $aa = $_POST['aa']; 
    324                 $mm = $_POST['mm']; 
    325                 $jj = $_POST['jj']; 
    326                 $hh = $_POST['hh']; 
    327                 $mn = $_POST['mn']; 
    328                 $ss = $_POST['ss']; 
    329                 $jj = ($jj > 31 ) ? 31 : $jj; 
    330                 $hh = ($hh > 23 ) ? $hh -24 : $hh; 
    331                 $mn = ($mn > 59 ) ? $mn -60 : $mn; 
    332                 $ss = ($ss > 59 ) ? $ss -60 : $ss; 
    333                 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 
    334         } 
    335  
    336         wp_update_comment( $_POST); 
    337 
    338  
    339 // Get an existing post and format it for editing. 
    340 function get_post_to_edit( $id ) { 
    341  
    342         $post = get_post( $id ); 
    343  
    344         $post->post_content = format_to_edit( $post->post_content, user_can_richedit() ); 
    345         $post->post_content = apply_filters( 'content_edit_pre', $post->post_content); 
    346  
    347         $post->post_excerpt = format_to_edit( $post->post_excerpt); 
    348         $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt); 
    349  
    350         $post->post_title = format_to_edit( $post->post_title ); 
    351         $post->post_title = apply_filters( 'title_edit_pre', $post->post_title ); 
    352  
    353         $post->post_password = format_to_edit( $post->post_password ); 
    354          
    355         $post->menu_order = (int) $post->menu_order; 
    356  
    357         if ( $post->post_type == 'page' ) 
    358                 $post->page_template = get_post_meta( $id, '_wp_page_template',