Make WordPress Core


Ignore:
Timestamp:
10/23/2009 04:32:56 AM (15 years ago)
Author:
azaozz
Message:

PressThis fixes from noel, fixes #11011

File:
1 edited

Legend:

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

    r12042 r12094  
    101101$image = isset($_GET['i']) ? $_GET['i'] : '';
    102102
    103 if ( !empty($_GET['ajax']) ) {
    104     switch ($_GET['ajax']) {
     103if ( !empty($_REQUEST['ajax']) ) {
     104    switch ($_REQUEST['ajax']) {
    105105        case 'video': ?>
    106106            <script type="text/javascript" charset="utf-8">
     
    108108                jQuery('.select').click(function() {
    109109                    append_editor(jQuery('#embed-code').val());
    110                     jQuery('#extra_fields').hide();
    111                     jQuery('#extra_fields').html('');
     110                    jQuery('#extra-fields').hide();
     111                    jQuery('#extra-fields').html('');
    112112                });
    113113                jQuery('.close').click(function() {
    114                     jQuery('#extra_fields').hide();
    115                     jQuery('#extra_fields').html('');
     114                    jQuery('#extra-fields').hide();
     115                    jQuery('#extra-fields').html('');
    116116                });
    117117            /* ]]> */
     
    193193         */
    194194        function get_images_from_uri($uri) {
     195            $uri = preg_replace('/\/#.+?$/','', $uri);
    195196            if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
    196197                return "'".html_entity_decode($uri)."'";
     
    199200                return '';
    200201            $host = parse_url($uri);
    201             $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif)[^<>\'\"]*)(\2)([^>]*)\/*>/is';
     202            $pattern = '/<img ([^>]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/is';
    202203            preg_match_all($pattern, $content, $matches);
    203204            if ( empty($matches[0]) )
     
    216217            return "'" . implode("','", $sources) . "'";
    217218        }
    218         $url = urldecode($url);
     219        $url = wp_kses(urldecode($url), null);
    219220        echo 'new Array('.get_images_from_uri($url).')';
    220 
    221221        break;
    222222
     
    225225        var last = null
    226226        var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
     227        if(photostorage == false) {
    227228        var my_src = eval(
    228229            jQuery.ajax({
     
    250251            }
    251252        }
    252 
     253        }
    253254        for (i = 0; i < my_src.length; i++) {
    254255            img = new Image();
     
    295296            src = jQuery('#this_photo').val();
    296297            pick(src, desc);
    297             jQuery('#extra_fields').hide();
    298             jQuery('#extra_fields').html('');
     298            jQuery('#extra-fields').hide();
     299            jQuery('#extra-fields').html('');
    299300            return false;
    300301        }
    301 
    302         jQuery(document).ready(function() {
    303             jQuery('#extra_fields').html('<div class="postbox"><h2>Photo <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul id="actions"><li><a href="#" id="photo_add_url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
    304             jQuery('.close').click(function() {
    305                 jQuery('#extra_fields').hide();
    306                 jQuery('#extra_fields').html('');
    307             });
    308             jQuery('.refresh').click(function() {
    309                         show('photo');
    310                     });
     302            jQuery('#extra-fields').html('<div class="postbox"><h2>Add Photos <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
    311303            jQuery('#img_container').html(strtoappend);
    312             jQuery('#photo_add_url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
    313             tb_init('#extra_fields .thickbox');
    314 
    315 
    316         });
    317304        <?php break;
    318305}
     
    329316<?php
    330317    add_thickbox();
    331     wp_enqueue_style('press-this');
    332     wp_enqueue_style('press-this-ie');
     318    wp_enqueue_style( 'press-this' );
     319    wp_enqueue_style( 'press-this-ie');
    333320    wp_enqueue_style( 'colors' );
    334321    wp_enqueue_script( 'post' );
    335     wp_enqueue_script('editor');
     322    wp_enqueue_script( 'editor' );
    336323?>
    337324<script type="text/javascript">
     
    340327var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
    341328var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this';
     329var photostorage = false;
    342330//]]>
    343331</script>
     
    377365
    378366    function show(tab_name) {
    379         jQuery('#extra_fields').html('');
    380         jQuery('#extra_fields').show();
     367        jQuery('#extra-fields').html('');
    381368        switch(tab_name) {
    382369            case 'video' :
    383                 jQuery('#extra_fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
     370                jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
    384371                    <?php
    385372                    $content = '';
     
    403390                    jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
    404391                });
     392                jQuery('#extra-fields').show();
    405393                return false;
    406394                break;
    407395            case 'photo' :
    408                 jQuery('#extra_fields').before('<p id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></p>');
    409                 jQuery.ajax({
    410                     type: "GET",
    411                     cache : false,
    412                     url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
    413                     data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
    414                     dataType : "script",
    415                     success : function() {
    416                         jQuery('#waiting').remove();
    417                     }
    418                 });
     396                function setup_photo_actions() {
     397                    jQuery('.close').click(function() {
     398                        jQuery('#extra-fields').hide();
     399                        jQuery('#extra-fields').html('');
     400                    });
     401                    jQuery('.refresh').click(function() {
     402                        photostorage = false;
     403                        show('photo');
     404                    });
     405                    jQuery('#photo-add-url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
     406                    tb_init('#extra-fields .thickbox');
     407                    jQuery('#waiting').hide();
     408                    jQuery('#extra-fields').show();
     409                }
     410                jQuery('#extra-fields').before('<div id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></div>');
     411               
     412                if(photostorage == false) {
     413                    jQuery.ajax({
     414                        type: "GET",
     415                        cache : false,
     416                        url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
     417                        data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
     418                        dataType : "script",
     419                        success : function(data) {
     420                            eval(data);
     421                            photostorage = jQuery('#extra-fields').html();
     422                            setup_photo_actions();
     423                        }
     424                    });
     425                } else {
     426                    jQuery('#extra-fields').html(photostorage);
     427                    setup_photo_actions();
     428                }
    419429                return false;
    420430                break;
     
    423433    jQuery(document).ready(function($) {
    424434        //resize screen
    425         window.resizeTo(720,570);
     435        window.resizeTo(720,540);
    426436        // set button actions
    427437        jQuery('#photo_button').click(function() { show('photo'); return false; });
     
    450460    <div id="side-info-column">
    451461        <div class="sleeve">
    452             <h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>
     462            <h1 id="viewsite"><a href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>
    453463
    454464            <?php wp_nonce_field('press-this') ?>
     
    462472
    463473            <div id="submitdiv" class="stuffbox">
     474                <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
     475                    <br/>
     476                </div>
    464477                <h3><?php _e('Publish') ?></h3>
    465478                <div class="inside">
     
    477490
    478491            <div id="categorydiv" class="stuffbox">
     492                <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
     493                    <br/>
     494                </div>
    479495                <h3><?php _e('Categories') ?></h3>
    480496                <div class="inside">
    481497
    482498                    <div id="categories-all" class="tabs-panel">
     499
    483500                        <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
    484501                            <?php wp_category_checklist($post_ID, false) ?>
     
    500517
    501518            <div id="tagsdiv-post_tag" class="stuffbox" >
     519                <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
     520                    <br/>
     521                </div>
    502522                <h3><span><?php _e('Post Tags'); ?></span></h3>
    503523                <div class="inside">
     
    519539        </div>
    520540    </div>
    521 
    522541    <div class="posting">
    523542        <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
     
    531550        </div>
    532551
    533         <div id="extra_fields" style="display: none"></div>
     552        <div id="extra-fields" style="display: none"></div>
    534553
    535554        <div class="postdivrich">
    536             <ul id="actions">
     555            <ul id="actions" class="actions">
    537556
    538557                <li id="photo_button">
Note: See TracChangeset for help on using the changeset viewer.