]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/press-this.php
WordPress 4.1.3
[autoinstalls/wordpress.git] / wp-admin / press-this.php
index 0f2be6c539872e8217648bf4210fd6fe515f9bbf..6ae7341f3459a98002c81be19e5bb6fe3e84783c 100644 (file)
@@ -9,18 +9,16 @@
 define('IFRAME_REQUEST' , true);
 
 /** WordPress Administration Bootstrap */
 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 ) )
 
 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.
  *
 
 /**
  * Press It form handler.
  *
- * @package WordPress
- * @subpackage Press_This
  * @since 2.6.0
  *
  * @return int Post ID
  * @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) {
        $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);
                        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';
        $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';
 
        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);
        if ( is_wp_error($upload) ) {
                wp_delete_post($post_ID);
-               wp_die($upload);
+               wp_die( esc_html( $upload->get_error_message() ) );
        } else {
        } 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'] );
                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']) ) {
                        <h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3>
                        <div class="titlediv">
                                <div class="titlewrap">
                        <h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3>
                        <div class="titlediv">
                                <div class="titlewrap">
-                                       <input id="tb_this_photo_description" name="photo_description" class="tb_this_photo_description tbtitle text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/>
+                                       <input id="tb_this_photo_description" name="photo_description" class="tb_this_photo_description tbtitle text" type="text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/>
                                </div>
                        </div>
 
                        <p class="centered">
                                </div>
                        </div>
 
                        <p class="centered">
-                               <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" class="tb_this_photo" />
+                               <input type="hidden" name="this_photo" value="<?php echo esc_attr( $image ); ?>" id="tb_this_photo" class="tb_this_photo" />
                                <a href="#" class="select">
                                <a href="#" class="select">
-                                       <img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
+                                       <img src="<?php echo esc_url( $image ); ?>" alt="<?php esc_attr_e( 'Click to insert.' ); ?>" title="<?php esc_attr_e( 'Click to insert.' ); ?>" />
                                </a>
                        </p>
 
                                </a>
                        </p>
 
@@ -163,8 +161,6 @@ if ( !empty($_REQUEST['ajax']) ) {
                /**
                 * Retrieve all image URLs from given URI.
                 *
                /**
                 * Retrieve all image URLs from given URI.
                 *
-                * @package WordPress
-                * @subpackage Press_This
                 * @since 2.6.0
                 *
                 * @param string $uri
                 * @since 2.6.0
                 *
                 * @param string $uri
@@ -185,9 +181,10 @@ if ( !empty($_REQUEST['ajax']) ) {
                                return '';
                        $sources = array();
                        foreach ($matches[3] as $src) {
                                return '';
                        $sources = array();
                        foreach ($matches[3] as $src) {
-                               // if no http in url
+
+                               // If no http in URL.
                                if (strpos($src, 'http') === false)
                                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
                                        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': ?>
                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) {
                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' );
 
        wp_enqueue_style( 'colors' );
        wp_enqueue_script( 'post' );
+       add_thickbox();
        _wp_admin_html_begin();
 ?>
 <title><?php _e('Press This') ?></title>
        _wp_admin_html_begin();
 ?>
 <title><?php _e('Press This') ?></title>
@@ -309,9 +307,38 @@ var photostorage = false;
 </script>
 
 <?php
 </script>
 
 <?php
-       do_action('admin_print_styles');
-       do_action('admin_print_scripts');
-       do_action('admin_head');
+       /** This action is documented in wp-admin/admin-header.php */
+       do_action( 'admin_enqueue_scripts', 'press-this.php' );
+
+       /**
+        * Fires when styles are printed for the Press This admin page.
+        *
+        * @since 3.7.0
+        */
+       do_action( 'admin_print_styles-press-this.php' );
+
+       /** This action is documented in wp-admin/admin-header.php */
+       do_action( 'admin_print_styles' );
+
+       /**
+        * Fires when scripts are printed for the Press This admin page.
+        *
+        * @since 3.7.0
+        */
+       do_action( 'admin_print_scripts-press-this.php' );
+
+       /** This action is documented in wp-admin/admin-header.php */
+       do_action( 'admin_print_scripts' );
+
+       /**
+        * Fires in the head tag on the Press This admin page.
+        *
+        * @since 3.7.0
+        */
+       do_action( 'admin_head-press-this.php' );
+
+       /** This action is documented in wp-admin/admin-header.php */
+       do_action( 'admin_head' );
 ?>
        <script type="text/javascript">
        var wpActiveEditor = 'content';
 ?>
        <script type="text/javascript">
        var wpActiveEditor = 'content';
@@ -412,12 +439,16 @@ var photostorage = false;
                }
        }
        jQuery(document).ready(function($) {
                }
        }
        jQuery(document).ready(function($) {
-               //resize screen
-               window.resizeTo(740,580);
-               // set button actions
+               var $contnet = $( '#content' );
+
+               // Resize screen.
+               window.resizeTo(760,580);
+
+               // Set button actions.
                jQuery('#photo_button').click(function() { show('photo'); return false; });
                jQuery('#video_button').click(function() { show('video'); return false; });
                jQuery('#photo_button').click(function() { show('photo'); return false; });
                jQuery('#video_button').click(function() { show('video'); return false; });
-               // auto select
+
+               // Auto select.
                <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
                        show('video');
                <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
                <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
                        show('video');
                <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
@@ -431,6 +462,12 @@ var photostorage = false;
                $('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
                        $(this).siblings('.inside').toggle();
                });
                $('#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() ) );
+               }
        });
 </script>
 </head>
        });
 </script>
 </head>
@@ -560,7 +597,6 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
        <div class="posting">
 
                <div id="wphead">
        <div class="posting">
 
                <div id="wphead">
-                       <img id="header-logo" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" alt="" width="16" height="16" />
                        <h1 id="site-heading">
                                <a href="<?php echo get_option('home'); ?>/" target="_blank">
                                        <span id="site-title"><?php bloginfo('name'); ?></span>
                        <h1 id="site-heading">
                                <a href="<?php echo get_option('home'); ?>/" target="_blank">
                                        <span id="site-title"><?php bloginfo('name'); ?></span>
@@ -581,7 +617,7 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
 
                <div id="titlediv">
                        <div class="titlewrap">
 
                <div id="titlediv">
                        <div class="titlewrap">
-                               <input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
+                               <input name="title" id="title" class="text" type="text" value="<?php echo esc_attr($title);?>"/>
                        </div>
                </div>
 
                        </div>
                </div>
 
@@ -645,8 +681,10 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
        </tr></table>
 </div>
 <?php
        </tr></table>
 </div>
 <?php
-do_action('admin_footer');
-do_action('admin_print_footer_scripts');
+/** This action is documented in wp-admin/admin-footer.php */
+do_action( 'admin_footer' );
+/** This action is documented in wp-admin/admin-footer.php */
+do_action( 'admin_print_footer_scripts' );
 ?>
 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
 </body>
 ?>
 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
 </body>