WordPress.org

Make WordPress Core

Ticket #6813: press-this-noel-6-16-08.diff

File press-this-noel-6-16-08.diff, 7.9 KB (added by noel, 5 years ago)

June 16 5:39pm

  • wp-admin/press-this.php

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    
    Property changes on: wp-admin/images/loading-publish.gif
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
     
    66<?php  
    77function press_it() { 
    88        #define some basic variables 
    9         $quick['post_status'] = 'publish'; 
     9        $quick['post_status'] = $_REQUEST['post_status']; 
    1010        $quick['post_category'] = $_REQUEST['post_category']; 
    1111        $quick['tags_input'] = $_REQUEST['tags_input']; 
    1212        $quick['post_title'] = $_REQUEST['post_title']; 
     
    4242                        break;   
    4343                } 
    4444        # set the post_content 
    45         $quick['post_content'] = $content; 
     45        $quick['post_content'] = str_replace('<br />', "\n", preg_replace('/<\/?p>/','',$content)); 
    4646 
    4747        #error handling for $post 
    4848        if ( is_wp_error($post_ID) ) { 
     
    5757        return $post_ID; 
    5858} 
    5959 
    60  
    61 function category_div() { ?> 
    62         <div id="categories"> 
    63                 <div class="submitbox" id="submitpost"> 
    64                         <div id="previewview"></div> 
    65                         <div class="inside"> 
    66                                 <h2><?php _e('Categories') ?></h2> 
    67                                 <div id="categories-all"> 
    68                                         <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 
    69                                                 <?php wp_category_checklist() ?> 
    70                                         </ul> 
    71                                 </div> 
    72                                 <h2><?php _e('Tags') ?></h2> 
    73                                 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p> 
    74                                 <div id="tagchecklist"></div> 
    75                                  
    76                         </div> 
    77                         <p class="submit">          
    78                         <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 
    79                         <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/> 
    80                         </p> 
    81                 </div>   
    82 <?php } 
    83  
    8460# For submitted posts. 
    8561if ( 'post' == $_REQUEST['action'] ) {  
    8662        check_admin_referer('press-this'); $post_ID = press_it(); ?> 
     
    11086 
    11187// Ajax Requests 
    11288$title = wp_specialchars(stripslashes($_GET['t'])); 
    113 $selection = trim(wp_specialchars(str_replace("\n", ' ',stripslashes($_GET['s'])))); 
    114 $url = $_GET['u']; 
     89$selection = trim(str_replace('\\n', "<br />", wp_specialchars(js_escape($_GET['s'])))); 
     90$url = clean_url($_GET['u']); 
    11591$image = $_GET['i']; 
    11692if($_REQUEST['ajax'] == 'thickbox') { ?> 
    11793        <script type="text/javascript" charset="utf-8">  
     
    130106                jQuery('.select').click(function() { 
    131107                        image_selector(); 
    132108                }); 
    133  
    134109        </script> 
    135110        <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 
    136111        <div class="titlewrap"> 
     
    154129} 
    155130 
    156131if($_REQUEST['ajax'] == 'photo_images') { 
    157         error_log('photo images'); 
    158132        function get_images_from_uri($uri) { 
    159133                if(preg_match('/\.(jpg|png|gif)/', $uri))  
    160134                        return "'".$uri."'"; 
    161                  
     135                         
    162136                $content = wp_remote_fopen($uri); 
    163                 $host = parse_url($uri); 
    164                  
    165137                if ( false === $content ) return ''; 
    166138                 
     139                $host = parse_url($uri); 
     140                 
    167141                $pattern = '/<img ([^>]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/is'; 
    168142                preg_match_all($pattern, $content, $matches); 
    169                 if ( empty($matches[1]) ) { error_log('empty'); return ''; }; 
     143                 
     144                if ( empty($matches[1]) ) return ''; 
     145                 
    170146                $sources = array(); 
    171  
    172147                foreach ($matches[3] as $src) { 
    173                         error_log($src); 
    174                         #if ( false !== strpos($src, '&') ) continue; 
    175                                 if(strpos($src, 'http') === false) { 
    176                                         if(strpos($src, '../') === false && strpos($src, './') === false) { 
    177                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 
    178                                         } else { 
    179                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 
    180                                         } 
    181                                 } 
    182                                  
    183                                 $sources[] = $src; 
     148                        if(strpos($src, 'http') === false) 
     149                                if(strpos($src, '../') === false && strpos($src, './') === false) 
     150                                        $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 
     151                                else 
     152                                        $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 
     153                                                                                 
     154                        $sources[] = $src; 
    184155                } 
    185156                return "'" . implode("','", $sources) . "'"; 
    186157        }  
     
    226197                                if (img.width && img.height) { 
    227198                                        if (img.width * img.height < 2500) skip = true; 
    228199                                        aspect = img.width / img.height; 
    229                                         if (aspect > 1) { // Image is wide 
    230                                                 scale = 75 / img.width; 
    231                                         } else { // Image is tall or square 
    232                                                 scale = 75 / img.height; 
    233                                         } 
     200                                        scale = (aspect > 1) ? (75 / img.width) : (75 / img.height); 
     201                                         
    234202                                        if (scale < 1) { 
    235203                                                w = parseInt(img.width * scale); 
    236204                                                h = parseInt(img.height * scale); 
     
    252220<?php die; } 
    253221 
    254222if($_REQUEST['ajax'] == 'photo') { ?> 
    255          
    256223                <div class="photolist"></div> 
    257          
    258224                <small><?php _e('Click images to select:') ?></small> 
    259225                <div class="titlewrap"> 
    260226                        <div id="img_container"></div> 
    261227                </div> 
    262228<?php die; } 
    263  
    264229?> 
    265230<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    266231<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 
     
    317282                                accessibility_focus : false, 
    318283                                tab_focus : ":next", 
    319284                                plugins : "safari,inlinepopups", 
    320                                 entities : "38,amp,60,lt,62,gt" 
     285                                entities : "38,amp,60,lt,62,gt", 
     286                                force_p_newlines : true 
    321287                        }); 
    322288    <?php } ?> 
    323289 
     
    349315                jQuery("#post_type").val(type); 
    350316        } 
    351317        function set_editor(text) { 
     318 
    352319                if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent(''); 
    353320                if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); 
    354321        } 
     
    369336                                jQuery('#content_type').show(); 
    370337                                set_menu('text'); 
    371338                                set_title('<?php _e('Text') ?>'); 
    372                                 <?php if($selection) { ?> 
    373                                 set_editor('<?php echo '<p><a href="'.$url.'">'.$selection.'</a> </p> '; ?>'); 
    374                                 <?php } else { ?> 
    375                                 set_editor('<?php echo '<p><a href="'.$url.'">'.$title.'</a> </p> '; ?>'); 
    376                                 <?php } ?> 
     339 
    377340                                return false; 
    378341                        break; 
    379342                        case 'quote' : 
     
    499462                                        </div> 
    500463                                         
    501464                                </div> 
    502                                 <?php category_div(); ?> 
     465                                <div id="categories"> 
     466                                        <div class="submitbox" id="submitpost"> 
     467                                        <div id="previewview"></div> 
     468                                        <div class="inside"> 
     469                                                <h2><?php _e('Categories') ?></h2> 
     470                                                <div id="categories-all"> 
     471                                                        <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 
     472                                                                <?php wp_category_checklist() ?> 
     473                                                        </ul> 
     474                                                </div> 
     475                                                <h2><?php _e('Tags') ?></h2> 
     476                                                <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p> 
     477                                                <div id="tagchecklist"></div> 
     478                                        </div> 
     479                                        <label for="post_status" id="post_status"><input type="radio" name="post_status" value="publish" checked="checked" id="published" />Published <input type="radio" name="post_status" value="draft" id="unpubplished" /> Unpublished</label> 
     480                                         
     481                                        <p class="submit">          
     482                                                <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 
     483                                                <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/> 
     484                                        </p> 
     485                                </div> 
     486                                 
     487                                 
    503488                        </form>          
    504489                                         
    505490</body> 
  • wp-admin/css/press-this.css

     
    111111.howto { 
    112112font-size: 11px; 
    113113} 
    114 #newtag { padding: 3px; } 
     114#newtag { width: 60%; padding: 3px; } 
    115115 
    116116#wphead { 
    117117        height: 2em; 
     
    451451} 
    452452#photo_saving { 
    453453margin-bottom: 8px; 
     454} 
     455 
     456#post_status { 
     457margin-left: 10px; 
     458margin-bottom: 1em; 
     459display: block; 
    454460} 
     461 No newline at end of file