Make WordPress Core


Ignore:
Timestamp:
07/09/2008 09:39:36 PM (15 years ago)
Author:
ryan
Message:

Press This: CSS cleanup, photo input newline breaks, fixes short_tags problem. Props noel. see #6813

File:
1 edited

Legend:

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

    r8302 r8303  
    22require_once('admin.php');
    33
    4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' )); ?>
    5 
    6 <?php
     4if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin&#8217; uh?' ) );
    75
    86function preg_quote2($string) {
    97    return str_replace('/', '\/', preg_quote($string));
     8}
     9function aposfix($text) {
     10    $translation_table[chr(34)] = '&quot;';
     11    $translation_table[chr(38)] = '&';
     12    $translation_table[chr(39)] = '&apos;';
     13    return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($text, $translation_table));   
    1014}
    1115function press_it() {
     
    3135           
    3236            foreach($_REQUEST['photo_src'] as $key => $image) {
    33                 #quote for matching
     37                // escape quote for matching
    3438                $quoted = preg_quote2($image);
    3539               
     
    5155            break; 
    5256        }
    53     # set the post_content
     57    // set the post_content
    5458    $quick['post_content'] = str_replace('<br />', "\n", preg_replace('/<\/?p>/','',$content));
    5559
    56     #error handling for $post
     60    // error handling for $post
    5761    if ( is_wp_error($post_ID)) {
    5862        wp_die($id);
    5963        wp_delete_post($post_ID);
    60     #error handling for media_sideload
     64    // error handling for media_sideload
    6165    } elseif ( is_wp_error($upload)) {
    6266        wp_die($upload);
     
    6973}
    7074
    71 # For submitted posts.
     75// For submitted posts.
    7276if ( 'post' == $_REQUEST['action'] ) {
    7377    check_admin_referer('press-this'); $post_ID = press_it(); ?>
    74    
    7578    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    7679    <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
     
    8992    ?>
    9093    </head>
    91     <body class="press-this">
    92        
    93         <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&amp;post=<?php echo $post_ID; ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
    94        
     94    <body class="press-this">   
     95        <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&amp;post=<?php echo $post_ID; ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>   
    9596        <div id="footer">
    9697        <p><?php
     
    100101        ?></p>
    101102        </div>
    102         <?php do_action('admin_footer', ''); ?>
    103        
     103        <?php do_action('admin_footer', ''); ?>     
    104104    </body>
    105105    </html>
    106106    <?php die;
    107 }
    108 
    109 
    110 function aposfix($text) {
    111     $translation_table[chr(34)] = '&quot;';
    112     $translation_table[chr(38)] = '&';
    113     $translation_table[chr(39)] = '&apos;';
    114     return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($text, $translation_table));   
    115107}
    116108
     
    179171if($_REQUEST['ajax'] == 'photo_images') {
    180172    function get_images_from_uri($uri) {
    181         if(preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com'))
     173        if( preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com') )
    182174            return "'".$uri."'";
    183175
     
    212204
    213205if($_REQUEST['ajax'] == 'photo_js') { ?>
    214    
    215    
    216206    // gather images and load some default JS
    217    
    218207    var last = null
    219208    var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
     
    258247            jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
    259248            jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
    260             append_editor('<img src="' + img +'" alt="' + desc + '" />');
     249            append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" /></p>');
    261250        }
    262251        tinyMCE.activeEditor.resizeToContent();
     
    278267    });
    279268   
    280 <?php die; }
     269<?php die;
     270}
    281271
    282272if($_REQUEST['ajax'] == 'photo') { ?>
     
    288278            <div id="img_container"></div>
    289279        </div>
    290 <?php die; }
     280<?php die;
     281}
    291282?>
    292283<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    378369   
    379370    function set_editor(text) {
    380 
    381371        if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent('');
    382372        if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text);
     
    400390                <?php } else { ?>
    401391                    set_editor("<a href='<?php echo $url ?>'><?php echo $title; ?></a>");
    402                 <? } ?>
     392                <?php } ?>
    403393                return false;
    404394                break;
     
    412402                set_menu('video');
    413403                set_title('<?php _e('Caption') ?>');
    414                
    415404                jQuery('#extra_fields').show();
    416405                jQuery('body').addClass('video_split');
     
    418407                    <?php
    419408                    if ( preg_match("/youtube\.com\/watch/i", $url) ) {
    420                     list($domain, $video_id) = split("v=", $url);
    421                     $content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>'; ?>
     409                        list($domain, $video_id) = split("v=", $url);
     410                        $content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
     411                       
     412                    } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
     413                        list($domain, $video_id) = split(".com/", $url);
     414                        $content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />  <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
    422415                   
    423                     <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
    424                    
    425                     list($domain, $video_id) = split(".com/", $url);
    426                     $content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />  <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
    427                    
    428                     if ( trim($selection) == '' )
    429                         $selection = '<a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a>';
     416                        if ( trim($selection) == '' )
     417                            $selection = '<a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a>';
     418                                       
    430419                    } else {
    431420                        $content = $selection;
    432                     } ?>
     421                    }
     422                   
     423                    ?>
    433424                    jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>');
    434425                   
     
    444435                <?php } else { ?>
    445436                    set_editor("<a href='<?php echo $url ?>'><?php echo $title; ?></a>");
    446                 <? } ?>
     437                <?php } ?>
    447438                jQuery('#extra_fields').show();
    448439                jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>');
     
    469460            show(tab_name);
    470461        });
    471        
    472462        // Set default tabs
    473463        <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
     
    479469        <?php } ?>
    480470    });
    481    
     471
    482472</script>
    483473</head>
Note: See TracChangeset for help on using the changeset viewer.