Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/press-this.php

    r8552 r8332  
    3535
    3636                        foreach( (array) $_REQUEST['photo_src'] as $key => $image) {
    37                                
     37                                // escape quote for matching
     38                                $quoted = preg_quote2($image);
     39
    3840                                // see if files exist in content - we don't want to upload non-used selected files.
    39                                 if( strpos($_REQUEST['content'], $image) !== false ) {
     41                                if( strpos($_REQUEST['content'], $quoted) !== false ) {
    4042                                        $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]);
    41                                          
    4243                                        // Replace the POSTED content <img> with correct uploaded ones.
    43                                         // escape quote for matching
    44                                         $quoted = preg_quote2($image);
    4544                                        if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content);
    4645                                }
    … …  
    185184                $host = parse_url($uri);
    186185
    187                 $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
     186                $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif)[^<>\'\"]*)(\2)([^>\/]*)\/*>/is';
    188187                preg_match_all($pattern, $content, $matches);
    189                
     188
    190189                if ( empty($matches[1]) ) return '';
    191190
    192191                $sources = array();
    193192                foreach ($matches[3] as $src) {
    194                         // if no http in url
    195193                        if(strpos($src, 'http') === false)
    196                                 // if it doesn't have a relative uri
    197                                 if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === true)
     194                                if(strpos($src, '../') === false && strpos($src, './') === false)
    198195                                        $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
    199196                                else
    200                                         $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
    201                        
     197                                        $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src);
     198
    202199                        $sources[] = clean_url($src);
    203200                }
    … …  
    250247
    251248        function pick(img, desc) {
    252                 if (img) {
    253                         if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
     249                if (img) { 
     250                        length = jQuery('.photolist input').length;
    254251                        if(length == 0) length = 1;
    255252                        jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
    256253                        jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
    257                         append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" class="aligncenter"/></p>');
     254                        append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" /></p>');
    258255                }
    259256                tinyMCE.activeEditor.resizeToContent();
    … …  
    270267
    271268        jQuery(document).ready(function() {
    272                 jQuery('#extra_fields').html('<div class="photolist"></div><small id="photo_directions"><?php _e("Click images to select:") ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e("Add from URL") ?> +</a></span></small><div class="titlewrap"><div id="img_container"></div></div>');
    273269                jQuery('#img_container').html(strtoappend);
    274270                jQuery('#photo_add_url').attr('href', '?ajax=thickbox_url&height=200&width=500');
    … …  
    280276
    281277if($_REQUEST['ajax'] == 'photo') { ?>
    282 
     278                <div class="photolist"></div>
     279
     280                <small id="photo_directions"><?php _e('Click images to select:') ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e('Add from URL') ?> +</a></span></small>
     281
     282                <div class="titlewrap">
     283                        <div id="img_container"></div>
     284                </div>
    283285<?php die;
    284286}
    … …  
    321323                                language : "<?php echo $language; ?>",
    322324                                width: "100%",
    323                                 height: "300",
    324325                                theme : "advanced",
    325326                                theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink",
    … …  
    445446                                jQuery('#extra_fields').show();
    446447                                jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>');
     448                                jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']).'/?ajax=photo&u='.attribute_escape($url); ?>');
    447449                                jQuery.ajax({
    448450                                        type: "GET",
    … …  
    471473                <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
    472474                        show('video');
    473                 <?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
     475                        <?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
    474476                        show('photo');
    475477                <?php } ?>
    … …  
    504506                        <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2>
    505507                        <div class="editor-container">
    506                                 <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea>
     508                                <textarea name="content" id="content" style="width:100%;" class="mceEditor"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea>
    507509                        </div>
    508510                </div>
Note: See TracChangeset for help on using the changeset viewer.