web/wp-admin/press-this.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Press_This
     6  * @subpackage Press_This
     7  */
     7  */
     8 
     8 
       
     9 define('IFRAME_REQUEST' , true);
       
    10 
     9 /** WordPress Administration Bootstrap */
    11 /** WordPress Administration Bootstrap */
    10 require_once('admin.php');
    12 require_once('./admin.php');
       
    13 
    11 header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    14 header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    12 
    15 
    13 if ( ! current_user_can('edit_posts') )
    16 if ( ! current_user_can('edit_posts') )
    14 	wp_die( __( 'Cheatin’ uh?' ) );
    17 	wp_die( __( 'Cheatin’ uh?' ) );
    15 
       
    16 /**
       
    17  * Convert characters.
       
    18  *
       
    19  * @package WordPress
       
    20  * @subpackage Press_This
       
    21  * @since 2.6.0
       
    22  *
       
    23  * @param string $text
       
    24  * @return string
       
    25  */
       
    26 function aposfix($text) {
       
    27 	$translation_table[chr(34)] = '"';
       
    28 	$translation_table[chr(38)] = '&';
       
    29 	$translation_table[chr(39)] = ''';
       
    30 	return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($text, $translation_table));
       
    31 }
       
    32 
    18 
    33 /**
    19 /**
    34  * Press It form handler.
    20  * Press It form handler.
    35  *
    21  *
    36  * @package WordPress
    22  * @package WordPress
    38  * @since 2.6.0
    24  * @since 2.6.0
    39  *
    25  *
    40  * @return int Post ID
    26  * @return int Post ID
    41  */
    27  */
    42 function press_it() {
    28 function press_it() {
    43 	// define some basic variables
    29 
    44 	$quick['post_status'] = 'draft'; // set as draft first
    30 	$post = get_default_post_to_edit();
    45 	$quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
    31 	$post = get_object_vars($post);
    46 	$quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null;
    32 	$post_ID = $post['ID'] = (int) $_POST['post_id'];
    47 	$quick['post_title'] = ( trim($_POST['title']) != '' ) ? $_POST['title'] : '  ';
    33 
    48 	$quick['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : ''; 
    34 	if ( !current_user_can('edit_post', $post_ID) )
    49 
    35 		wp_die(__('You are not allowed to edit this post.'));
    50 	// insert the post with nothing in it, to get an ID
    36 
    51 	$post_ID = wp_insert_post($quick, true);
    37 	$post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : '';
    52 	if ( is_wp_error($post_ID) )
    38 	$post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : '';
    53 		wp_die($post_ID);
    39 	$post['post_title'] = isset($_POST['title']) ? $_POST['title'] : '';
    54 
       
    55 	$content = isset($_POST['content']) ? $_POST['content'] : '';
    40 	$content = isset($_POST['content']) ? $_POST['content'] : '';
    56 
    41 
    57 	$upload = false;
    42 	$upload = false;
    58 	if( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
    43 	if ( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
    59 		foreach( (array) $_POST['photo_src'] as $key => $image) {
    44 		foreach( (array) $_POST['photo_src'] as $key => $image) {
    60 			// see if files exist in content - we don't want to upload non-used selected files.
    45 			// see if files exist in content - we don't want to upload non-used selected files.
    61 			if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
    46 			if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
    62 				$desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
    47 				$desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
    63 				$upload = media_sideload_image($image, $post_ID, $desc);
    48 				$upload = media_sideload_image($image, $post_ID, $desc);
    64 
    49 
    65 				// Replace the POSTED content <img> with correct uploaded ones. Regex contains fix for Magic Quotes
    50 				// Replace the POSTED content <img> with correct uploaded ones. Regex contains fix for Magic Quotes
    66 				if( !is_wp_error($upload) )
    51 				if ( !is_wp_error($upload) )
    67 					$content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
    52 					$content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
    68 			}
    53 			}
    69 		}
    54 		}
    70 	}
    55 	}
    71 	// set the post_content and status
    56 	// set the post_content and status
    72 	$quick['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft';
    57 	$post['post_content'] = $content;
    73 	$quick['post_content'] = $content;
    58 	if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) )
       
    59 		$post['post_status'] = 'publish';
       
    60 	elseif ( isset( $_POST['review'] ) )
       
    61 		$post['post_status'] = 'pending';
       
    62 	else
       
    63 		$post['post_status'] = 'draft';
       
    64 
    74 	// error handling for media_sideload
    65 	// error handling for media_sideload
    75 	if ( is_wp_error($upload) ) {
    66 	if ( is_wp_error($upload) ) {
    76 		wp_delete_post($post_ID);
    67 		wp_delete_post($post_ID);
    77 		wp_die($upload);
    68 		wp_die($upload);
    78 	} else {
    69 	} else {
    79 		$quick['ID'] = $post_ID;
    70 		// Post formats
    80 		wp_update_post($quick);
    71 		if ( isset( $_POST['post_format'] ) ) {
       
    72 			if ( current_theme_supports( 'post-formats', $_POST['post_format'] ) )
       
    73 				set_post_format( $post_ID, $_POST['post_format'] );
       
    74 			elseif ( '0' == $_POST['post_format'] )
       
    75 				set_post_format( $post_ID, false );
       
    76 		}
       
    77 
       
    78 		$post_ID = wp_update_post($post);
    81 	}
    79 	}
       
    80 
    82 	return $post_ID;
    81 	return $post_ID;
    83 }
    82 }
    84 
    83 
    85 // For submitted posts.
    84 // For submitted posts.
    86 if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
    85 if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
    87 	check_admin_referer('press-this');
    86 	check_admin_referer('press-this');
    88 	$post_ID = press_it();
    87 	$posted = $post_ID = press_it();
    89 	$posted =  $post_ID;
       
    90 } else {
    88 } else {
    91 	$post_ID = 0;
    89 	$post = get_default_post_to_edit('post', true);
       
    90 	$post_ID = $post->ID;
    92 }
    91 }
    93 
    92 
    94 // Set Variables
    93 // Set Variables
    95 $title = isset( $_GET['t'] ) ? trim( strip_tags( aposfix( stripslashes( $_GET['t'] ) ) ) ) : '';
    94 $title = isset( $_GET['t'] ) ? trim( strip_tags( html_entity_decode( stripslashes( $_GET['t'] ) , ENT_QUOTES) ) ) : '';
    96 $selection = isset( $_GET['s'] ) ? trim( htmlspecialchars( html_entity_decode( aposfix( stripslashes( $_GET['s'] ) ) ) ) ) : '';
    95 
       
    96 $selection = '';
       
    97 if ( !empty($_GET['s']) ) {
       
    98 	$selection = str_replace('&apos;', "'", stripslashes($_GET['s']));
       
    99 	$selection = trim( htmlspecialchars( html_entity_decode($selection, ENT_QUOTES) ) );
       
   100 }
       
   101 
    97 if ( ! empty($selection) ) {
   102 if ( ! empty($selection) ) {
    98 	$selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
   103 	$selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
    99 	$selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>';
   104 	$selection = '<p>' . str_replace('<p></p>', '', $selection) . '</p>';
   100 }
   105 }
   101 
   106 
   102 $url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
   107 $url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
   103 $image = isset($_GET['i']) ? $_GET['i'] : '';
   108 $image = isset($_GET['i']) ? $_GET['i'] : '';
   104 
   109 
   119 			/* ]]> */
   124 			/* ]]> */
   120 			</script>
   125 			</script>
   121 			<div class="postbox">
   126 			<div class="postbox">
   122 				<h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
   127 				<h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
   123 				<div class="inside">
   128 				<div class="inside">
   124 					<textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo wp_htmledit_pre( $selection ); ?></textarea>
   129 					<textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo esc_textarea( $selection ); ?></textarea>
   125 					<p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
   130 					<p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
   126 				</div>
   131 				</div>
   127 			</div>
   132 			</div>
   128 			<?php break;
   133 			<?php break;
   129 
   134 
   132 				/* <![CDATA[ */
   137 				/* <![CDATA[ */
   133 				jQuery('.cancel').click(function() {
   138 				jQuery('.cancel').click(function() {
   134 					tb_remove();
   139 					tb_remove();
   135 				});
   140 				});
   136 				jQuery('.select').click(function() {
   141 				jQuery('.select').click(function() {
   137 					image_selector();
   142 					image_selector(this);
   138 				});
   143 				});
   139 				/* ]]> */
   144 				/* ]]> */
   140 			</script>
   145 			</script>
   141 			<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>
   142 			<div class="titlediv">
   147 			<div class="titlediv">
   143 				<div class="titlewrap">
   148 				<div class="titlewrap">
   144 					<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="tb_this_photo_description tbtitle text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/>
   145 				</div>
   150 				</div>
   146 			</div>
   151 			</div>
   147 
   152 
   148 			<p class="centered">
   153 			<p class="centered">
   149 				<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" class="tb_this_photo" />
   150 				<a href="#" class="select">
   155 				<a href="#" class="select">
   151 					<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
   156 					<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
   152 				</a>
   157 				</a>
   153 			</p>
   158 			</p>
   154 
   159 
   155 			<p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
   160 			<p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
   156 			<?php break;
       
   157 
       
   158 		case 'photo_thickbox_url': ?>
       
   159 			<script type="text/javascript" charset="utf-8">
       
   160 				/* <![CDATA[ */
       
   161 				jQuery('.cancel').click(function() {
       
   162 					tb_remove();
       
   163 				});
       
   164 
       
   165 				jQuery('.select').click(function() {
       
   166 					image_selector();
       
   167 				});
       
   168 				/* ]]> */
       
   169 			</script>
       
   170 			<h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>
       
   171 			<div class="titlediv">
       
   172 				<div class="titlewrap">
       
   173 					<input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />
       
   174 				</div>
       
   175 			</div>
       
   176 			<h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>
       
   177 			<div id="titlediv">
       
   178 				<div class="titlewrap">
       
   179 					<input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
       
   180 				</div>
       
   181 			</div>
       
   182 
       
   183 			<p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
       
   184 			<?php break;
   161 			<?php break;
   185 	case 'photo_images':
   162 	case 'photo_images':
   186 		/**
   163 		/**
   187 		 * Retrieve all image URLs from given URI.
   164 		 * Retrieve all image URLs from given URI.
   188 		 *
   165 		 *
   193 		 * @param string $uri
   170 		 * @param string $uri
   194 		 * @return string
   171 		 * @return string
   195 		 */
   172 		 */
   196 		function get_images_from_uri($uri) {
   173 		function get_images_from_uri($uri) {
   197 			$uri = preg_replace('/\/#.+?$/','', $uri);
   174 			$uri = preg_replace('/\/#.+?$/','', $uri);
   198 			if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
   175 			if ( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
   199 				return "'" . esc_attr( html_entity_decode($uri) ) . "'";
   176 				return "'" . esc_attr( html_entity_decode($uri) ) . "'";
   200 			$content = wp_remote_fopen($uri);
   177 			$content = wp_remote_fopen($uri);
   201 			if ( false === $content )
   178 			if ( false === $content )
   202 				return '';
   179 				return '';
   203 			$host = parse_url($uri);
   180 			$host = parse_url($uri);
   207 			if ( empty($matches[0]) )
   184 			if ( empty($matches[0]) )
   208 				return '';
   185 				return '';
   209 			$sources = array();
   186 			$sources = array();
   210 			foreach ($matches[3] as $src) {
   187 			foreach ($matches[3] as $src) {
   211 				// if no http in url
   188 				// if no http in url
   212 				if(strpos($src, 'http') === false)
   189 				if (strpos($src, 'http') === false)
   213 					// if it doesn't have a relative uri
   190 					// if it doesn't have a relative uri
   214 					if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
   191 					if ( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
   215 						$src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
   192 						$src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
   216 					else
   193 					else
   217 						$src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
   194 						$src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
   218 				$sources[] = esc_attr($src);
   195 				$sources[] = esc_url($src);
   219 			}
   196 			}
   220 			return "'" . implode("','", $sources) . "'";
   197 			return "'" . implode("','", $sources) . "'";
   221 		}
   198 		}
   222 		$url = wp_kses(urldecode($url), null);
   199 		$url = wp_kses(urldecode($url), null);
   223 		echo 'new Array('.get_images_from_uri($url).')';
   200 		echo 'new Array('.get_images_from_uri($url).')';
   228 		var last = null
   205 		var last = null
   229 		var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
   206 		var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
   230 		if(photostorage == false) {
   207 		if(photostorage == false) {
   231 		var my_src = eval(
   208 		var my_src = eval(
   232 			jQuery.ajax({
   209 			jQuery.ajax({
   233 		   		type: "GET",
   210 				type: "GET",
   234 		   		url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
   211 				url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
   235 				cache : false,
   212 				cache : false,
   236 				async : false,
   213 				async : false,
   237 		   		data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
   214 				data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
   238 				dataType : "script"
   215 				dataType : "script"
   239 			}).responseText
   216 			}).responseText
   240 		);
   217 		);
   241 		if(my_src.length == 0) {
   218 		if(my_src.length == 0) {
   242 			var my_src = eval(
   219 			var my_src = eval(
   243 				jQuery.ajax({
   220 				jQuery.ajax({
   244 		   			type: "GET",
   221 					type: "GET",
   245 		   			url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
   222 					url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
   246 					cache : false,
   223 					cache : false,
   247 					async : false,
   224 					async : false,
   248 		   			data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
   225 					data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
   249 					dataType : "script"
   226 					dataType : "script"
   250 				}).responseText
   227 				}).responseText
   251 			);
   228 			);
   252 			if(my_src.length == 0) {
   229 			if(my_src.length == 0) {
   253 				strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
   230 				strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
   291 				insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
   268 				insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
   292 			}
   269 			}
   293 			return false;
   270 			return false;
   294 		}
   271 		}
   295 
   272 
   296 		function image_selector() {
   273 		function image_selector(el) {
       
   274 			var desc, src, parent = jQuery(el).closest('#photo-add-url-div');
       
   275 
       
   276 			if ( parent.length ) {
       
   277 				desc = parent.find('input.tb_this_photo_description').val() || '';
       
   278 				src = parent.find('input.tb_this_photo').val() || ''
       
   279 			} else {
       
   280 				desc = jQuery('#tb_this_photo_description').val() || '';
       
   281 				src = jQuery('#tb_this_photo').val() || ''
       
   282 			}
       
   283 
   297 			tb_remove();
   284 			tb_remove();
   298 			desc = jQuery('#this_photo_description').val();
       
   299 			src = jQuery('#this_photo').val();
       
   300 			pick(src, desc);
   285 			pick(src, desc);
   301 			jQuery('#extra-fields').hide();
   286 			jQuery('#extra-fields').hide();
   302 			jQuery('#extra-fields').html('');
   287 			jQuery('#extra-fields').html('');
   303 			return false;
   288 			return false;
   304 		}
   289 		}
   305 			jQuery('#extra-fields').html('<div class="postbox"><h2>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="thickbox 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>');
   290 
   306 			jQuery('#img_container').html(strtoappend);
   291 		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>');
       
   292 		jQuery('#img_container').html(strtoappend);
   307 		<?php break;
   293 		<?php break;
   308 }
   294 }
   309 die;
   295 die;
   310 }
   296 }
   311 
   297 
   312 ?>
       
   313 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
   314 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
       
   315 <head>
       
   316 	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
       
   317 	<title><?php _e('Press This') ?></title>
       
   318 
       
   319 <?php
       
   320 	add_thickbox();
       
   321 	wp_enqueue_style( 'press-this' );
       
   322 	wp_enqueue_style( 'press-this-ie');
       
   323 	wp_enqueue_style( 'colors' );
   298 	wp_enqueue_style( 'colors' );
   324 	wp_enqueue_script( 'post' );
   299 	wp_enqueue_script( 'post' );
   325 	wp_enqueue_script( 'editor' );
   300 	_wp_admin_html_begin();
   326 ?>
   301 ?>
       
   302 <title><?php _e('Press This') ?></title>
   327 <script type="text/javascript">
   303 <script type="text/javascript">
   328 //<![CDATA[
   304 //<![CDATA[
   329 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
   305 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
   330 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
   306 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
   331 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this';
   307 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
   332 var photostorage = false;
   308 var photostorage = false;
   333 //]]>
   309 //]]>
   334 </script>
   310 </script>
   335 
   311 
   336 <?php
   312 <?php
   337 	do_action('admin_print_styles');
   313 	do_action('admin_print_styles');
   338 	do_action('admin_print_scripts');
   314 	do_action('admin_print_scripts');
   339 	do_action('admin_head');
   315 	do_action('admin_head');
   340 
       
   341 	if ( user_can_richedit() )
       
   342 		wp_tiny_mce( true, array( 'height' => '370' ) );
       
   343 ?>
   316 ?>
   344 	<script type="text/javascript">
   317 	<script type="text/javascript">
       
   318 	var wpActiveEditor = 'content';
       
   319 
   345 	function insert_plain_editor(text) {
   320 	function insert_plain_editor(text) {
   346 		edCanvas = document.getElementById('content');
   321 		if ( typeof(QTags) != 'undefined' )
   347 		edInsertContent(edCanvas, text);
   322 			QTags.insertContent(text);
   348 	}
   323 	}
   349 	function set_editor(text) {
   324 	function set_editor(text) {
   350 		if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
   325 		if ( '' == text || '<p></p>' == text )
   351 		if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
   326 			text = '<p><br /></p>';
       
   327 
       
   328 		if ( tinyMCE.activeEditor )
       
   329 			tinyMCE.execCommand('mceSetContent', false, text);
   352 	}
   330 	}
   353 	function insert_editor(text) {
   331 	function insert_editor(text) {
   354 		if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
   332 		if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
   355 			tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
   333 			tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
   356 		} else {
   334 		} else {
   358 		}
   336 		}
   359 	}
   337 	}
   360 	function append_editor(text) {
   338 	function append_editor(text) {
   361 		if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
   339 		if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
   362 			tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
   340 			tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
   363 			tinyMCE.execCommand('mceCleanup');
       
   364 		} else {
   341 		} else {
   365 			insert_plain_editor(text);
   342 			insert_plain_editor(text);
   366 		}
   343 		}
   367 	}
   344 	}
   368 
   345 
   372 			case 'video' :
   349 			case 'video' :
   373 				jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
   350 				jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
   374 					<?php
   351 					<?php
   375 					$content = '';
   352 					$content = '';
   376 					if ( preg_match("/youtube\.com\/watch/i", $url) ) {
   353 					if ( preg_match("/youtube\.com\/watch/i", $url) ) {
   377 						list($domain, $video_id) = split("v=", $url);
   354 						list($domain, $video_id) = explode("v=", $url);
   378 						$video_id = esc_attr($video_id);
   355 						$video_id = esc_attr($video_id);
   379 						$content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
   356 						$content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
   380 
   357 
   381 					} elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
   358 					} elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
   382 						list($domain, $video_id) = split(".com/", $url);
   359 						list($domain, $video_id) = explode(".com/", $url);
   383 						$video_id = esc_attr($video_id);
   360 						$video_id = esc_attr($video_id);
   384 						$content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />	<embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
   361 						$content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />	<embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
   385 
   362 
   386 						if ( trim($selection) == '' )
   363 						if ( trim($selection) == '' )
   387 							$selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>';
   364 							$selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>';
   403 					});
   380 					});
   404 					jQuery('.refresh').click(function() {
   381 					jQuery('.refresh').click(function() {
   405 						photostorage = false;
   382 						photostorage = false;
   406 						show('photo');
   383 						show('photo');
   407 					});
   384 					});
   408 					jQuery('#photo-add-url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
   385 					jQuery('#photo-add-url').click(function(){
   409 					tb_init('#extra-fields .thickbox');
   386 						var form = jQuery('#photo-add-url-div').clone();
       
   387 						jQuery('#img_container').empty().append( form.show() );
       
   388 					});
   410 					jQuery('#waiting').hide();
   389 					jQuery('#waiting').hide();
   411 					jQuery('#extra-fields').show();
   390 					jQuery('#extra-fields').show();
   412 				}
   391 				}
   413 				jQuery('#extra-fields').before('<div id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></div>');
   392 
   414 				
   393 				jQuery('#waiting').show();
   415 				if(photostorage == false) {
   394 				if(photostorage == false) {
   416 					jQuery.ajax({
   395 					jQuery.ajax({
   417 						type: "GET",
   396 						type: "GET",
   418 						cache : false,
   397 						cache : false,
   419 						url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
   398 						url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
   433 				break;
   412 				break;
   434 		}
   413 		}
   435 	}
   414 	}
   436 	jQuery(document).ready(function($) {
   415 	jQuery(document).ready(function($) {
   437 		//resize screen
   416 		//resize screen
   438 		window.resizeTo(720,540);
   417 		window.resizeTo(720,580);
   439 		// set button actions
   418 		// set button actions
   440     	jQuery('#photo_button').click(function() { show('photo'); return false; });
   419 		jQuery('#photo_button').click(function() { show('photo'); return false; });
   441 		jQuery('#video_button').click(function() { show('video'); return false; });
   420 		jQuery('#video_button').click(function() { show('video'); return false; });
   442 		// auto select
   421 		// auto select
   443 		<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
   422 		<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
   444 			show('video');
   423 			show('video');
   445 		<?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
   424 		<?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
   446 			show('video');
   425 			show('video');
   447 		<?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
   426 		<?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
   448 			show('photo');
   427 			show('photo');
   449 		<?php } ?>
   428 		<?php } ?>
   450 		jQuery('#title').unbind();
   429 		jQuery('#title').unbind();
   451 		jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
   430 		jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
   452 
   431 
   454 			$(this).siblings('.inside').toggle();
   433 			$(this).siblings('.inside').toggle();
   455 		});
   434 		});
   456 	});
   435 	});
   457 </script>
   436 </script>
   458 </head>
   437 </head>
   459 <body class="press-this wp-admin">
   438 <?php
   460 <div id="wphead"></div>
   439 $admin_body_class = ( is_rtl() ) ? 'rtl' : '';
       
   440 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
       
   441 ?>
       
   442 <body class="press-this wp-admin <?php echo $admin_body_class; ?>">
   461 <form action="press-this.php?action=post" method="post">
   443 <form action="press-this.php?action=post" method="post">
   462 <div id="poststuff" class="metabox-holder">
   444 <div id="poststuff" class="metabox-holder">
   463 	<div id="side-info-column">
   445 	<div id="side-sortables" class="press-this-sidebar">
   464 		<div class="sleeve">
   446 		<div class="sleeve">
   465 			<h1 id="viewsite"><a href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>
       
   466 
       
   467 			<?php wp_nonce_field('press-this') ?>
   447 			<?php wp_nonce_field('press-this') ?>
   468 			<input type="hidden" name="post_type" id="post_type" value="text"/>
   448 			<input type="hidden" name="post_type" id="post_type" value="text"/>
   469 			<input type="hidden" name="autosave" id="autosave" />
   449 			<input type="hidden" name="autosave" id="autosave" />
   470 			<input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
   450 			<input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
   471 			<input type="hidden" id="prev_status" name="prev_status" value="draft" />
   451 			<input type="hidden" id="prev_status" name="prev_status" value="draft" />
       
   452 			<input type="hidden" id="post_id" name="post_id" value="<?php echo (int) $post_ID; ?>" />
   472 
   453 
   473 			<!-- This div holds the photo metadata -->
   454 			<!-- This div holds the photo metadata -->
   474 			<div class="photolist"></div>
   455 			<div class="photolist"></div>
   475 
   456 
   476 			<div id="submitdiv" class="stuffbox">
   457 			<div id="submitdiv" class="postbox">
   477 				<div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
   458 				<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
   478 					<br/>
   459 				<h3 class="hndle"><?php _e('Press This') ?></h3>
   479 				</div>
       
   480 				<h3><?php _e('Publish') ?></h3>
       
   481 				<div class="inside">
   460 				<div class="inside">
       
   461 					<p id="publishing-actions">
       
   462 					<?php
       
   463 						submit_button( __( 'Save Draft' ), 'button', 'draft', false, array( 'id' => 'save' ) );
       
   464 						if ( current_user_can('publish_posts') ) {
       
   465 							submit_button( __( 'Publish' ), 'primary', 'publish', false );
       
   466 						} else {
       
   467 							echo '<br /><br />';
       
   468 							submit_button( __( 'Submit for Review' ), 'primary', 'review', false );
       
   469 						} ?>
       
   470 						<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="saving" style="display:none;" />
       
   471 					</p>
       
   472 					<?php if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) :
       
   473 							$post_formats = get_theme_support( 'post-formats' );
       
   474 							if ( is_array( $post_formats[0] ) ) :
       
   475 								$default_format = get_option( 'default_post_format', '0' );
       
   476 						?>
   482 					<p>
   477 					<p>
   483 						<input class="button" type="submit" name="draft" value="<?php esc_attr_e('Save Draft') ?>" id="save" />
   478 						<label for="post_format"><?php _e( 'Post Format:' ); ?>
   484 						<?php if ( current_user_can('publish_posts') ) { ?>
   479 						<select name="post_format" id="post_format">
   485 							<input class="button-primary" type="submit" name="publish" value="<?php esc_attr_e('Publish') ?>" id="publish" />
   480 							<option value="0"><?php _ex( 'Standard', 'Post format' ); ?></option>
   486 						<?php } else { ?>
   481 						<?php foreach ( $post_formats[0] as $format ): ?>
   487 							<br /><br /><input class="button-primary" type="submit" name="review" value="<?php esc_attr_e('Submit for Review') ?>" id="review" />
   482 							<option<?php selected( $default_format, $format ); ?> value="<?php echo esc_attr( $format ); ?>"> <?php echo esc_html( get_post_format_string( $format ) ); ?></option>
   488 						<?php } ?>
   483 						<?php endforeach; ?>
   489 						<img src="images/wpspin_light.gif" alt="" id="saving" style="display:none;" />
   484 						</select></label>
   490 					</p>
   485 					</p>
       
   486 					<?php endif; endif; ?>
   491 				</div>
   487 				</div>
   492 			</div>
   488 			</div>
   493 
   489 
   494 			<div id="categorydiv" class="stuffbox">
   490 			<?php $tax = get_taxonomy( 'category' ); ?>
   495 				<div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
   491 			<div id="categorydiv" class="postbox">
   496 					<br/>
   492 				<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
   497 				</div>
   493 				<h3 class="hndle"><?php _e('Categories') ?></h3>
   498 				<h3><?php _e('Categories') ?></h3>
       
   499 				<div class="inside">
   494 				<div class="inside">
   500 
   495 				<div id="taxonomy-category" class="categorydiv">
   501 					<div id="categories-all" class="tabs-panel">
   496 
   502 
   497 					<ul id="category-tabs" class="category-tabs">
   503 						<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
   498 						<li class="tabs"><a href="#category-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
   504 							<?php wp_category_checklist($post_ID, false) ?>
   499 						<li class="hide-if-no-js"><a href="#category-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
       
   500 					</ul>
       
   501 
       
   502 					<div id="category-pop" class="tabs-panel" style="display: none;">
       
   503 						<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
       
   504 							<?php $popular_ids = wp_popular_terms_checklist( 'category' ); ?>
   505 						</ul>
   505 						</ul>
   506 					</div>
   506 					</div>
   507 
   507 
   508 					<div id="category-adder" class="wp-hidden-children">
   508 					<div id="category-all" class="tabs-panel">
   509 						<a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
   509 						<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
   510 						<p id="category-add" class="wp-hidden-child">
   510 							<?php wp_terms_checklist($post_ID, array( 'taxonomy' => 'category', 'popular_cats' => $popular_ids ) ) ?>
   511 							<label class="screen-reader-text" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
   511 						</ul>
   512 							<label class="screen-reader-text" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
       
   513 							<input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
       
   514 							<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
       
   515 							<span id="category-ajax-response"></span>
       
   516 						</p>
       
   517 					</div>
   512 					</div>
       
   513 
       
   514 					<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
       
   515 					<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
       
   516 					<?php endif; ?>
       
   517 					<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
       
   518 						<div id="category-adder" class="wp-hidden-children">
       
   519 							<h4>
       
   520 								<a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3">
       
   521 									<?php printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>
       
   522 								</a>
       
   523 							</h4>
       
   524 							<p id="category-add" class="category-add wp-hidden-child">
       
   525 								<label class="screen-reader-text" for="newcategory"><?php echo $tax->labels->add_new_item; ?></label>
       
   526 								<input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
       
   527 								<label class="screen-reader-text" for="newcategory_parent">
       
   528 									<?php echo $tax->labels->parent_item_colon; ?>
       
   529 								</label>
       
   530 								<?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3 ) ); ?>
       
   531 								<input type="button" id="category-add-submit" class="add:categorychecklist:category-add button category-add-submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
       
   532 								<?php wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); ?>
       
   533 								<span id="category-ajax-response"></span>
       
   534 							</p>
       
   535 						</div>
       
   536 					<?php endif; ?>
       
   537 				</div>
   518 				</div>
   538 				</div>
   519 			</div>
   539 			</div>
   520 
   540 
   521 			<div id="tagsdiv-post_tag" class="stuffbox" >
   541 			<div id="tagsdiv-post_tag" class="postbox">
   522 				<div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
   542 				<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
   523 					<br/>
   543 				<h3><span><?php _e('Tags'); ?></span></h3>
   524 				</div>
       
   525 				<h3><span><?php _e('Post Tags'); ?></span></h3>
       
   526 				<div class="inside">
   544 				<div class="inside">
   527 					<div class="tagsdiv" id="post_tag">
   545 					<div class="tagsdiv" id="post_tag">
   528 						<p class="jaxtag">
   546 						<div class="jaxtag">
   529 							<label class="screen-reader-text" for="newtag"><?php _e('Post Tags'); ?></label>
   547 							<label class="screen-reader-text" for="newtag"><?php _e('Tags'); ?></label>
   530 							<input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
   548 							<input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
   531 							<div class="ajaxtag">
   549 							<div class="ajaxtag">
   532 								<input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
   550 								<input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
   533 								<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
   551 								<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
   534 							</div>
   552 							</div>
   535 						</p>
   553 						</div>
   536 						<div class="tagchecklist"></div>
   554 						<div class="tagchecklist"></div>
   537 					</div>
   555 					</div>
   538 					<p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags in Post Tags'); ?></a></p>
   556 					<p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags'); ?></a></p>
   539 				</div>
   557 				</div>
   540 			</div>
   558 			</div>
   541 		</div>
   559 		</div>
   542 	</div>
   560 	</div>
   543 	<div class="posting">
   561 	<div class="posting">
   544 		<?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
   562 
   545 		<div id="message" class="updated fade"><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>
   563 		<div id="wphead">
       
   564 			<img id="header-logo" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" alt="" width="16" height="16" />
       
   565 			<h1 id="site-heading">
       
   566 				<a href="<?php echo get_option('home'); ?>/" target="_blank">
       
   567 					<span id="site-title"><?php bloginfo('name'); ?></span>
       
   568 				</a>
       
   569 			</h1>
       
   570 		</div>
       
   571 
       
   572 		<?php
       
   573 		if ( isset($posted) && intval($posted) ) {
       
   574 			$post_ID = intval($posted); ?>
       
   575 			<div id="message" class="updated">
       
   576 			<p><strong><?php _e('Your post has been saved.'); ?></strong>
       
   577 			<a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink($post_ID); ?>"><?php _e('View post'); ?></a>
       
   578 			| <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit Post'); ?></a>
       
   579 			| <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p>
       
   580 			</div>
   546 		<?php } ?>
   581 		<?php } ?>
   547 
   582 
   548 		<div id="titlediv">
   583 		<div id="titlediv">
   549 			<div class="titlewrap">
   584 			<div class="titlewrap">
   550 				<input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
   585 				<input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
   551 			</div>
   586 			</div>
   552 		</div>
   587 		</div>
   553 
   588 
       
   589 		<div id="waiting" style="display: none"><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> <?php esc_html_e( 'Loading...' ); ?></div>
       
   590 
   554 		<div id="extra-fields" style="display: none"></div>
   591 		<div id="extra-fields" style="display: none"></div>
   555 
   592 
   556 		<div class="postdivrich">
   593 		<div class="postdivrich">
   557 			<ul id="actions" class="actions">
   594 		<?php
   558 
   595 
   559 				<li id="photo_button">
   596 		$editor_settings = array(
   560 					Add: <?php if ( current_user_can('upload_files') ) { ?><a title="<?php _e('Insert an Image'); ?>" href="#">
   597 			'teeny' => true,
   561 <img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
   598 			'textarea_rows' => '15'
   562 					<?php } ?>
   599 		);
   563 				</li>
   600 
   564 				<li id="video_button">
   601 		$content = '';
   565 					<a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
   602 		if ( $selection )
   566 				</li>
   603 			$content .= $selection;
   567 				<?php if( user_can_richedit() ) { ?>
   604 
   568 				<li id="switcher">
   605 		if ( $url ) {
   569 					<?php wp_print_scripts( 'quicktags' ); ?>
   606 			$content .= '<p>';
   570 					<?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
   607 
   571 					<a id="edButtonHTML" onclick="switchEditors.go('content', 'html');"><?php _e('HTML'); ?></a>
   608 			if ( $selection )
   572 					<a id="edButtonPreview" class="active" onclick="switchEditors.go('content', 'tinymce');"><?php _e('Visual'); ?></a>
   609 				$content .= __('via ');
   573 					<div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('content')" /></div>
   610 
   574 				</li>
   611 			$content .= sprintf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) );
   575 				<?php } ?>
   612 		}
   576 			</ul>
   613 
   577 			<div id="quicktags"></div>
   614 		remove_action( 'media_buttons', 'media_buttons' );
   578 			<div class="editor-container">
   615 		add_action( 'media_buttons', 'press_this_media_buttons' );
   579 				<textarea name="content" id="content" style="width:100%;" class="theEditor" rows="15"><?php
   616 		function press_this_media_buttons() {
   580 					if ( $selection )
   617 			_e( 'Add:' );
   581 						echo wp_richedit_pre($selection);
   618 
   582 					if ( $url ) {
   619 			if ( current_user_can('upload_files') ) {
   583 						echo '<p>';
   620 				?>
   584 						if ( $selection )
   621 				<a id="photo_button" title="<?php esc_attr_e('Insert an Image'); ?>" href="#">
   585 							_e('via ');
   622 				<img alt="<?php esc_attr_e('Insert an Image'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-image.gif?ver=20100531' ) ); ?>"/></a>
   586 						printf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) );
   623 				<?php
   587 					}
   624 			}
   588 				?></textarea>
   625 			?>
   589 			</div>
   626 			<a id="video_button" title="<?php esc_attr_e('Embed a Video'); ?>" href="#"><img alt="<?php esc_attr_e('Embed a Video'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-video.gif?ver=20100531' ) ); ?>"/></a>
       
   627 			<?php
       
   628 		}
       
   629 
       
   630 		wp_editor( $content, 'content', $editor_settings );
       
   631 
       
   632 		?>
   590 		</div>
   633 		</div>
   591 	</div>
   634 	</div>
   592 </div>
   635 </div>
   593 </form>
   636 </form>
   594 <?php do_action('admin_print_footer_scripts'); ?>
   637 <div id="photo-add-url-div" style="display:none;">
       
   638 	<table><tr>
       
   639 	<td><label for="this_photo"><?php _e('URL') ?></label></td>
       
   640 	<td><input type="text" id="this_photo" name="this_photo" class="tb_this_photo text" onkeypress="if(event.keyCode==13) image_selector(this);" /></td>
       
   641 	</tr><tr>
       
   642 	<td><label for="this_photo_description"><?php _e('Description') ?></label></td>
       
   643 	<td><input type="text" id="this_photo_description" name="photo_description" class="tb_this_photo_description text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/></td>
       
   644 	</tr><tr>
       
   645 	<td><input type="button" class="button" onclick="image_selector(this)" value="<?php esc_attr_e('Insert Image'); ?>" /></td>
       
   646 	</tr></table>
       
   647 </div>
       
   648 <?php
       
   649 do_action('admin_footer');
       
   650 do_action('admin_print_footer_scripts');
       
   651 ?>
   595 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
   652 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
   596 </body>
   653 </body>
   597 </html>
   654 </html>