Changeset 18570 for trunk/wp-admin/press-this.php
- Timestamp:
- 08/19/2011 01:14:56 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/press-this.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/press-this.php
r18530 r18570 27 27 */ 28 28 function press_it() { 29 // define some basic variables 30 $quick = array(); 31 $quick['post_status'] = 'draft'; // set as draft first 32 $quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null; 33 $quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null; 34 $quick['post_title'] = ( trim($_POST['title']) != '' ) ? $_POST['title'] : ' '; 35 $quick['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : ''; 36 37 // insert the post with nothing in it, to get an ID 38 $post_ID = wp_insert_post($quick, true); 39 if ( is_wp_error($post_ID) ) 40 wp_die($post_ID); 41 42 $content = isset($_POST['content']) ? $_POST['content'] : ''; 29 30 $post = get_default_post_to_edit('post', true); 31 $post_ID = $post['ID']; 32 $post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null; 33 $post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null; 34 $post['post_title'] = isset($_POST['title']) ? $_POST['title'] : ''; 35 $post['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : ''; 43 36 44 37 $upload = false; … … 58 51 // set the post_content and status 59 52 if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) ) 60 $ quick['post_status'] = 'publish';53 $post['post_status'] = 'publish'; 61 54 elseif ( isset( $_POST['review'] ) ) 62 $ quick['post_status'] = 'pending';55 $post['post_status'] = 'pending'; 63 56 else 64 $ quick['post_status'] = 'draft';65 $quick['post_content'] = $content; 57 $post['post_status'] = 'draft'; 58 66 59 // error handling for media_sideload 67 60 if ( is_wp_error($upload) ) { … … 81 74 } 82 75 83 $quick['ID'] = $post_ID; 84 wp_update_post($quick); 76 wp_update_post($post); 85 77 } 78 86 79 return $post_ID; 87 80 } … … 90 83 if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) { 91 84 check_admin_referer('press-this'); 92 $post_ID = press_it(); 93 $posted = $post_ID; 85 $posted = $post_ID = press_it(); 94 86 } else { 95 87 $post_ID = 0; … … 164 156 165 157 <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p> 166 <?php break;167 168 case 'photo_thickbox_url': ?>169 <script type="text/javascript" charset="utf-8">170 /* <![CDATA[ */171 jQuery('.cancel').click(function() {172 tb_remove();173 });174 175 jQuery('.select').click(function() {176 image_selector();177 });178 /* ]]> */179 </script>180 <h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>181 <div class="titlediv">182 <div class="titlewrap">183 <input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />184 </div>185 </div>186 <h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>187 <div id="titlediv">188 <div class="titlewrap">189 <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>190 </div>191 </div>192 193 <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>194 158 <?php break; 195 159 case 'photo_images': … … 313 277 return false; 314 278 } 315 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=" thickboxbutton"><?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>');279 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>'); 316 280 jQuery('#img_container').html(strtoappend); 317 281 <?php break; … … 328 292 329 293 <?php 330 add_thickbox();331 294 wp_enqueue_style( 'press-this' ); 332 295 wp_enqueue_style( 'press-this-ie'); … … 350 313 <script type="text/javascript"> 351 314 function insert_plain_editor(text) { 352 edCanvas = document.getElementById('content'); 353 edInsertContent(edCanvas, text); 315 edInsertContent(text); 354 316 } 355 317 function set_editor(text) { … … 411 373 show('photo'); 412 374 }); 413 jQuery('#photo-add-url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500'); 375 jQuery('#photo-add-url').click(function(){ 376 var form = jQuery('#photo-add-url-div').clone(); 377 jQuery('#img_container').empty().append( form.show() ); 378 }); 414 379 jQuery('#waiting').hide(); 415 380 jQuery('#extra-fields').show(); … … 440 405 jQuery(document).ready(function($) { 441 406 //resize screen 442 window.resizeTo(720,5 40);407 window.resizeTo(720,580); 443 408 // set button actions 444 409 jQuery('#photo_button').click(function() { show('photo'); return false; }); … … 462 427 </head> 463 428 <body class="press-this wp-admin"> 464 <?php465 if ( user_can_richedit() ) {466 wp_tiny_mce( true, array( 'height' => '370' ) );467 }468 ?>469 429 <form action="press-this.php?action=post" method="post"> 470 430 <div id="poststuff" class="metabox-holder"> … … 565 525 566 526 <div id="tagsdiv-post_tag" class="postbox"> 567 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>"> 568 <br/> 569 </div> 527 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>"><br /></div> 570 528 <h3><span><?php _e('Post Tags'); ?></span></h3> 571 529 <div class="inside"> … … 597 555 </div> 598 556 599 <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?> 600 <div id="message" class="updated"><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="<?php echo get_edit_post_link( $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> 557 <?php 558 if ( isset($posted) && intval($posted) ) { 559 $post_ID = intval($posted); ?> 560 <div id="message" class="updated"> 561 <p><strong><?php _e('Your post has been saved.'); ?></strong> 562 <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink($post_ID); ?>"><?php _e('View post'); ?></a> 563 | <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit Post'); ?></a> 564 | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p> 565 </div> 601 566 <?php } ?> 602 567 … … 610 575 611 576 <div class="postdivrich"> 612 <div id="editor-toolbar"> 613 <?php if ( user_can_richedit() ) : 614 wp_print_scripts( 'quicktags' ); 615 add_filter('the_editor_content', 'wp_richedit_pre'); ?> 616 <a id="edButtonHTML" onclick="switchEditors.go('content', 'html');"><?php _e('HTML'); ?></a> 617 <a id="edButtonPreview" class="active" onclick="switchEditors.go('content', 'tinymce');"><?php _e('Visual'); ?></a> 618 <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('content')" /></div> 619 <?php endif; ?> 620 621 <div id="media-buttons"> 622 <?php 623 _e( 'Add:' ); 624 625 if ( current_user_can('upload_files') ) : ?> 626 <a id="photo_button" title="<?php _e('Insert an Image'); ?>" href="#"> 627 <img alt="<?php _e('Insert an Image'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-image.gif?ver=20100531' ) ); ?>"/></a><?php 628 endif; 629 ?><a id="video_button" title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-video.gif?ver=20100531' ) ); ?>"/></a> 630 </div> 631 </div> 632 <div id="quicktags"></div> 633 <div class="editor-container"> 634 <textarea name="content" id="content" style="width:100%;" class="theEditor" rows="15"><?php 635 if ( $selection ) 636 echo wp_richedit_pre($selection); 637 if ( $url ) { 638 echo '<p>'; 639 if ( $selection ) 640 _e('via '); 641 printf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) ); 642 } 643 ?></textarea> 644 </div> 577 <?php 578 579 $editor_settings = array( 580 'teeny' => true, 581 'textarea_rows' => '15' 582 ); 583 584 $content = ''; 585 if ( $selection ) 586 $content .= $selection; 587 588 if ( $url ) { 589 $content .= '<p>'; 590 591 if ( $selection ) 592 $content .= __('via '); 593 594 $content .= sprintf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) ); 595 } 596 597 remove_action( 'media_buttons', 'media_buttons' ); 598 add_action( 'media_buttons', 'press_this_media_buttons' ); 599 function press_this_media_buttons() { 600 _e( 'Add:' ); 601 602 if ( current_user_can('upload_files') ) { 603 ?> 604 <a id="photo_button" title="<?php _e('Insert an Image'); ?>" href="#"> 605 <img alt="<?php _e('Insert an Image'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-image.gif?ver=20100531' ) ); ?>"/></a> 606 <?php 607 } 608 ?> 609 <a id="video_button" title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-video.gif?ver=20100531' ) ); ?>"/></a> 610 <?php 611 } 612 613 wp_editor( $content, 'content', $editor_settings ); 614 615 ?> 645 616 </div> 646 617 </div> 647 618 </div> 648 619 </form> 649 <?php do_action('admin_print_footer_scripts'); ?> 620 <div id="photo-add-url-div" style="display:none;"> 621 <table><tr> 622 <td><label for="this_photo"><?php _e('URL') ?></label></td> 623 <td><input type="text" id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" /></td> 624 </tr><tr> 625 <td><label for="this_photo_description"><?php _e('Description') ?></label></td> 626 <td><input type="text" id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/></td> 627 </tr><tr> 628 <td><input type="button" class="button" onclick="image_selector()" value="<?php _e('Insert Image'); ?>" /></td> 629 </tr></table> 630 </div> 631 <?php 632 do_action('admin_footer'); 633 do_action('admin_print_footer_scripts'); 634 ?> 650 635 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> 651 636 </body>
Note: See TracChangeset
for help on using the changeset viewer.