X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/61343b82c4f0da4c68e4c6373daafff4a81efdd1..1132430022383fdf47fa6cb9377300fd885297aa:/wp-admin/press-this.php diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index 0f2be6c5..6ae7341f 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -9,18 +9,16 @@ define('IFRAME_REQUEST' , true); /** WordPress Administration Bootstrap */ -require_once('./admin.php'); +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') ?> @@ -309,9 +307,38 @@ var photostorage = false; @@ -560,7 +597,6 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(