WordPress.org

Make WordPress Core

Ticket #2346: no-newlines.diff

File no-newlines.diff, 5.4 KB (added by NathanWong, 8 years ago)
  • wp-admin/admin-functions.php

     
    288288        $post->post_status = 'draft'; 
    289289        $post->comment_status = get_settings('default_comment_status'); 
    290290        $post->ping_status = get_settings('default_ping_status'); 
     291        $post->convert_newlines = 'open'; 
    291292        $post->post_pingback = get_settings('default_pingback_flag'); 
    292293        $post->post_category = get_settings('default_category'); 
    293294        $post->post_content = apply_filters('default_content', $post_content); 
  • wp-admin/edit-page-form.php

     
    4444 
    4545<div id="moremeta"> 
    4646<div id="grabit" class="dbx-group"> 
     47 
     48<fieldset id="newlinesdiv" class="dbx-box"> 
     49<h3 class="dbx-handle"><?php _e('Convert Newlines') ?></h3>  
     50<div class="dbx-content"><input name="convert_newlines" type="checkbox" id="convert_newlines" value="open" <?php checked($post->convert_newlines, 'open'); ?> /></div> 
     51</fieldset> 
     52 
    4753<fieldset id="commentstatusdiv" class="dbx-box"> 
    4854<h3 class="dbx-handle"><?php _e('Discussion') ?></h3> 
    4955<div class="dbx-content"> 
     
    5561</div> 
    5662</fieldset> 
    5763 
     64 
    5865<fieldset id="passworddiv" class="dbx-box"> 
    5966<h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>  
    6067<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div> 
  • wp-includes/functions-post.php

     
    3131        $post_name       = apply_filters('name_save_pre',      $post_name); 
    3232        $comment_status  = apply_filters('comment_status_pre', $comment_status); 
    3333        $ping_status     = apply_filters('ping_status_pre',    $ping_status); 
     34        $convert_newlines= apply_filters('convert_newlines',   $convert_newlines); 
    3435         
    3536        // Make sure we set a valid category 
    3637        if (0 == count($post_category) || !is_array($post_category)) { 
     
    8081        if ( empty($post_pingback) ) 
    8182                $post_pingback = get_option('default_pingback_flag'); 
    8283 
     84        if ( empty($convert_newlines) ) 
     85                $convert_newlines = 'closed'; 
     86 
    8387        if ( isset($to_ping) ) 
    8488                $to_ping = preg_replace('|\s+|', "\n", $to_ping); 
    8589        else 
     
    139143                        post_modified = '".current_time('mysql')."', 
    140144                        post_modified_gmt = '".current_time('mysql',1)."', 
    141145                        post_parent = '$post_parent', 
    142                         menu_order = '$menu_order' 
     146                        menu_order = '$menu_order', 
     147                        convert_newlines = '$convert_newlines' 
    143148                        WHERE ID = $post_ID"); 
    144149        } else { 
    145150                $wpdb->query( 
    146151                        "INSERT IGNORE INTO $wpdb->posts 
    147                         (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type) 
     152                        (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, convert_newlines) 
    148153                        VALUES 
    149                         ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')"); 
     154                        ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$convert_newlines')"); 
    150155                        $post_ID = $wpdb->insert_id;                     
    151156        } 
    152157 
  • wp-includes/functions.php

     
    11831183        if ( !isset($wp_filter[$tag]) ) { 
    11841184                return $string; 
    11851185        } 
     1186 
    11861187        foreach ($wp_filter[$tag] as $priority => $functions) { 
    11871188                if ( !is_null($functions) ) { 
    11881189                        foreach($functions as $function) { 
  • wp-includes/template-functions-post.php

     
    6363        global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages; 
    6464        global $preview; 
    6565        global $pagenow; 
     66        global $wp_filter; 
    6667        $output = ''; 
    6768 
    6869        if ( !empty($post->post_password) ) { // if there's a password 
     
    7778        else 
    7879                $file = $pagenow; //$_SERVER['PHP_SELF']; 
    7980 
     81        if ( 'closed' == $post->convert_newlines ) 
     82        { 
     83                // FIXME: Is wpautop important? I notice it does more than just newlines. Is that a problem? 
     84                remove_filter('the_content', 'wpautop'); 
     85        } 
     86 
    8087        $content = $pages[$page-1]; 
    8188        $content = explode('<!--more-->', $content, 2); 
    8289        if ( (preg_match('/<!--noteaser-->/', $post->post_content) && ((!$multipage) || ($page==1))) )