X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/e08b42e8ad054ec67522d7ac1aaae5dc68cb3d01..fc24d733700d6d2bd886ffa9188df5c78069b018:/wp-admin/press-this.php diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index 58394c8a..6ae7341f 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -14,13 +14,11 @@ require_once( dirname( __FILE__ ) . '/admin.php' ); header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) - wp_die( __( 'Cheatin’ uh?' ) ); + wp_die( __( 'Cheatin’ uh?' ), 403 ); /** * Press It form handler. * - * @package WordPress - * @subpackage Press_This * @since 2.6.0 * * @return int Post ID @@ -42,7 +40,7 @@ function press_it() { $upload = false; if ( !empty($_POST['photo_src']) && current_user_can('upload_files') ) { foreach( (array) $_POST['photo_src'] as $key => $image) { - // see if files exist in content - we don't want to upload non-used selected files. + // See if files exist in content - we don't want to upload non-used selected files. if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) { $desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : ''; $upload = media_sideload_image($image, $post_ID, $desc); @@ -53,7 +51,7 @@ function press_it() { } } } - // set the post_content and status + // Set the post_content and status. $post['post_content'] = $content; if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) ) $post['post_status'] = 'publish'; @@ -62,12 +60,12 @@ function press_it() { else $post['post_status'] = 'draft'; - // error handling for media_sideload + // Error handling for media_sideload. if ( is_wp_error($upload) ) { wp_delete_post($post_ID); - wp_die($upload); + wp_die( esc_html( $upload->get_error_message() ) ); } else { - // Post formats + // Post formats. if ( isset( $_POST['post_format'] ) ) { if ( current_theme_supports( 'post-formats', $_POST['post_format'] ) ) set_post_format( $post_ID, $_POST['post_format'] ); @@ -146,14 +144,14 @@ if ( !empty($_REQUEST['ajax']) ) {

- +

- + - <?php echo esc_attr(__('Click to insert.')); ?> + <?php esc_attr_e( 'Click to insert.' ); ?>

@@ -163,8 +161,6 @@ if ( !empty($_REQUEST['ajax']) ) { /** * Retrieve all image URLs from given URI. * - * @package WordPress - * @subpackage Press_This * @since 2.6.0 * * @param string $uri @@ -185,9 +181,10 @@ if ( !empty($_REQUEST['ajax']) ) { return ''; $sources = array(); foreach ($matches[3] as $src) { - // if no http in url + + // If no http in URL. if (strpos($src, 'http') === false) - // if it doesn't have a relative uri + // If it doesn't have a relative URI. if ( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0) $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); else @@ -201,7 +198,7 @@ if ( !empty($_REQUEST['ajax']) ) { break; case 'photo_js': ?> - // gather images and load some default JS + // Gather images and load some default JS. var last = null var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; if(photostorage == false) { @@ -297,6 +294,7 @@ die; wp_enqueue_style( 'colors' ); wp_enqueue_script( 'post' ); + add_thickbox(); _wp_admin_html_begin(); ?> <?php _e('Press This') ?> @@ -311,28 +309,34 @@ var photostorage = false; @@ -435,12 +439,16 @@ var photostorage = false; } } jQuery(document).ready(function($) { - //resize screen + var $contnet = $( '#content' ); + + // Resize screen. window.resizeTo(760,580); - // set button actions + + // Set button actions. jQuery('#photo_button').click(function() { show('photo'); return false; }); jQuery('#video_button').click(function() { show('video'); return false; }); - // auto select + + // Auto select. show('video'); @@ -454,6 +462,12 @@ var photostorage = false; $('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){ $(this).siblings('.inside').toggle(); }); + + if ( $( '#wp-content-wrap' ).hasClass( 'html-active' ) && window.switchEditors && + ( tinyMCEPreInit.mceInit.content && tinyMCEPreInit.mceInit.content.wpautop ) ) { + // The Text editor is default, run the initial content through pre_wpautop() to convert the paragraphs + $contnet.text( window.switchEditors.pre_wpautop( $contnet.text() ) ); + } }); @@ -603,7 +617,7 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
- +