WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/21/2011 06:32:39 PM (8 years ago)
Author:
azaozz
Message:

Press This: fix duplicate HTML IDs, add the 'default_post_to_edit' ID, fix minor RTL css, fixes #18989

File:
1 edited

Legend:

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

    r19229 r19381  
    2828function press_it() {
    2929
    30     $post = get_default_post_to_edit('post', true);
     30    $post = get_default_post_to_edit();
    3131    $post = get_object_vars($post);
    32     $post_ID = $post['ID'];
    33     $post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
    34     $post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null;
     32    $post_ID = $post['ID'] = (int) $_POST['post_id'];
     33
     34    if ( !current_user_can('edit_post', $post_ID) )
     35        wp_die(__('You are not allowed to edit this post.'));
     36
     37    $post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : '';
     38    $post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : '';
    3539    $post['post_title'] = isset($_POST['title']) ? $_POST['title'] : '';
    36     $post['post_content'] = isset($_POST['content']) ? $_POST['content'] : '';
     40    $content = isset($_POST['content']) ? $_POST['content'] : '';
    3741
    3842    $upload = false;
     
    5155    }
    5256    // set the post_content and status
     57    $post['post_content'] = $content;
    5358    if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) )
    5459        $post['post_status'] = 'publish';
     
    7176        }
    7277
    73         wp_update_post($post);
     78        $post_ID = wp_update_post($post);
    7479    }
    7580
     
    8287    $posted = $post_ID = press_it();
    8388} else {
    84     $post_ID = 0;
     89    $post = get_default_post_to_edit('post', true);
     90    $post_ID = $post->ID;
    8591}
    8692
     
    138144                /* ]]> */
    139145            </script>
    140             <h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
     146            <h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3>
    141147            <div class="titlediv">
    142148                <div class="titlewrap">
    143                     <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
     149                    <input id="tb_this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
    144150                </div>
    145151            </div>
    146152
    147153            <p class="centered">
    148                 <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="this_photo" />
     154                <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" />
    149155                <a href="#" class="select">
    150156                    <img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
     
    266272
    267273        function image_selector() {
     274            var desc = jQuery('#tb_this_photo_description').val() || '', src = jQuery('#tb_this_photo').val() || '';
     275
    268276            tb_remove();
    269             desc = jQuery('#this_photo_description').val();
    270             src = jQuery('#this_photo').val();
    271277            pick(src, desc);
    272278            jQuery('#extra-fields').hide();
     
    274280            return false;
    275281        }
    276             jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( '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="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>');
    277             jQuery('#img_container').html(strtoappend);
     282
     283        jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( '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="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>');
     284        jQuery('#img_container').html(strtoappend);
    278285        <?php break;
    279286}
     
    304311
    305312    function insert_plain_editor(text) {
    306         edInsertContent(text);
     313        if ( typeof(QTags) != 'undefined' )
     314            QTags.insertContent(text);
    307315    }
    308316    function set_editor(text) {
    309         if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
    310         if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
     317        if ( '' == text || '<p></p>' == text )
     318            text = '<p><br /></p>';
     319
     320        if ( tinyMCE.activeEditor )
     321            tinyMCE.execCommand('mceSetContent', false, text);
    311322    }
    312323    function insert_editor(text) {
     
    427438            <input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
    428439            <input type="hidden" id="prev_status" name="prev_status" value="draft" />
     440            <input type="hidden" id="post_id" name="post_id" value="<?php echo (int) $post_ID; ?>" />
    429441
    430442            <!-- This div holds the photo metadata -->
Note: See TracChangeset for help on using the changeset viewer.