]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/press-this.php
Wordpress 2.9.1-scripts
[autoinstalls/wordpress.git] / wp-admin / press-this.php
1 <?php
2 /**
3  * Press This Display and Handler.
4  *
5  * @package WordPress
6  * @subpackage Press_This
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
11 header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
12
13 if ( ! current_user_can('edit_posts') )
14         wp_die( __( 'Cheatin&#8217; 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)] = '&quot;';
28         $translation_table[chr(38)] = '&';
29         $translation_table[chr(39)] = '&apos;';
30         return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($text, $translation_table));
31 }
32
33 /**
34  * Press It form handler.
35  *
36  * @package WordPress
37  * @subpackage Press_This
38  * @since 2.6.0
39  *
40  * @return int Post ID
41  */
42 function press_it() {
43         // define some basic variables
44         $quick['post_status'] = 'draft'; // set as draft first
45         $quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
46         $quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null;
47         $quick['post_title'] = ( trim($_POST['title']) != '' ) ? $_POST['title'] : '  ';
48         $quick['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : ''; 
49
50         // insert the post with nothing in it, to get an ID
51         $post_ID = wp_insert_post($quick, true);
52         if ( is_wp_error($post_ID) )
53                 wp_die($post_ID);
54
55         $content = isset($_POST['content']) ? $_POST['content'] : '';
56
57         $upload = false;
58         if( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
59                 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.
61                         if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
62                                 $desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
63                                 $upload = media_sideload_image($image, $post_ID, $desc);
64
65                                 // Replace the POSTED content <img> with correct uploaded ones. Regex contains fix for Magic Quotes
66                                 if( !is_wp_error($upload) )
67                                         $content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
68                         }
69                 }
70         }
71         // set the post_content and status
72         $quick['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft';
73         $quick['post_content'] = $content;
74         // error handling for media_sideload
75         if ( is_wp_error($upload) ) {
76                 wp_delete_post($post_ID);
77                 wp_die($upload);
78         } else {
79                 $quick['ID'] = $post_ID;
80                 wp_update_post($quick);
81         }
82         return $post_ID;
83 }
84
85 // For submitted posts.
86 if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
87         check_admin_referer('press-this');
88         $post_ID = press_it();
89         $posted =  $post_ID;
90 } else {
91         $post_ID = 0;
92 }
93
94 // Set Variables
95 $title = isset( $_GET['t'] ) ? trim( strip_tags( aposfix( stripslashes( $_GET['t'] ) ) ) ) : '';
96 $selection = isset( $_GET['s'] ) ? trim( htmlspecialchars( html_entity_decode( aposfix( stripslashes( $_GET['s'] ) ) ) ) ) : '';
97 if ( ! empty($selection) ) {
98         $selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
99         $selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>';
100 }
101
102 $url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
103 $image = isset($_GET['i']) ? $_GET['i'] : '';
104
105 if ( !empty($_REQUEST['ajax']) ) {
106         switch ($_REQUEST['ajax']) {
107                 case 'video': ?>
108                         <script type="text/javascript" charset="utf-8">
109                         /* <![CDATA[ */
110                                 jQuery('.select').click(function() {
111                                         append_editor(jQuery('#embed-code').val());
112                                         jQuery('#extra-fields').hide();
113                                         jQuery('#extra-fields').html('');
114                                 });
115                                 jQuery('.close').click(function() {
116                                         jQuery('#extra-fields').hide();
117                                         jQuery('#extra-fields').html('');
118                                 });
119                         /* ]]> */
120                         </script>
121                         <div class="postbox">
122                                 <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
123                                 <div class="inside">
124                                         <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo wp_htmledit_pre( $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>
126                                 </div>
127                         </div>
128                         <?php break;
129
130                 case 'photo_thickbox': ?>
131                         <script type="text/javascript" charset="utf-8">
132                                 /* <![CDATA[ */
133                                 jQuery('.cancel').click(function() {
134                                         tb_remove();
135                                 });
136                                 jQuery('.select').click(function() {
137                                         image_selector();
138                                 });
139                                 /* ]]> */
140                         </script>
141                         <h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
142                         <div class="titlediv">
143                                 <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);?>"/>
145                                 </div>
146                         </div>
147
148                         <p class="centered">
149                                 <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="this_photo" />
150                                 <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.')); ?>" />
152                                 </a>
153                         </p>
154
155                         <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;
185         case 'photo_images':
186                 /**
187                  * Retrieve all image URLs from given URI.
188                  *
189                  * @package WordPress
190                  * @subpackage Press_This
191                  * @since 2.6.0
192                  *
193                  * @param string $uri
194                  * @return string
195                  */
196                 function get_images_from_uri($uri) {
197                         $uri = preg_replace('/\/#.+?$/','', $uri);
198                         if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
199                                 return "'" . esc_attr( html_entity_decode($uri) ) . "'";
200                         $content = wp_remote_fopen($uri);
201                         if ( false === $content )
202                                 return '';
203                         $host = parse_url($uri);
204                         $pattern = '/<img ([^>]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/i';
205                         $content = str_replace(array("\n","\t","\r"), '', $content);
206                         preg_match_all($pattern, $content, $matches);
207                         if ( empty($matches[0]) )
208                                 return '';
209                         $sources = array();
210                         foreach ($matches[3] as $src) {
211                                 // if no http in url
212                                 if(strpos($src, 'http') === false)
213                                         // if it doesn't have a relative uri
214                                         if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
215                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
216                                         else
217                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
218                                 $sources[] = esc_attr($src);
219                         }
220                         return "'" . implode("','", $sources) . "'";
221                 }
222                 $url = wp_kses(urldecode($url), null);
223                 echo 'new Array('.get_images_from_uri($url).')';
224                 break;
225
226         case 'photo_js': ?>
227                 // gather images and load some default JS
228                 var last = null
229                 var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
230                 if(photostorage == false) {
231                 var my_src = eval(
232                         jQuery.ajax({
233                                 type: "GET",
234                                 url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
235                                 cache : false,
236                                 async : false,
237                                 data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
238                                 dataType : "script"
239                         }).responseText
240                 );
241                 if(my_src.length == 0) {
242                         var my_src = eval(
243                                 jQuery.ajax({
244                                         type: "GET",
245                                         url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
246                                         cache : false,
247                                         async : false,
248                                         data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
249                                         dataType : "script"
250                                 }).responseText
251                         );
252                         if(my_src.length == 0) {
253                                 strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
254                         }
255                 }
256                 }
257                 for (i = 0; i < my_src.length; i++) {
258                         img = new Image();
259                         img.src = my_src[i];
260                         img_attr = 'id="img' + i + '"';
261                         skip = false;
262
263                         maybeappend = '<a href="?ajax=photo_thickbox&amp;i=' + encodeURIComponent(img.src) + '&amp;u=<?php echo urlencode($url); ?>&amp;height=400&amp;width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
264
265                         if (img.width && img.height) {
266                                 if (img.width >= 30 && img.height >= 30) {
267                                         aspect = img.width / img.height;
268                                         scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
269
270                                         w = img.width;
271                                         h = img.height;
272
273                                         if (scale < 1) {
274                                                 w = parseInt(img.width * scale);
275                                                 h = parseInt(img.height * scale);
276                                         }
277                                         img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
278                                         strtoappend += maybeappend;
279                                 }
280                         } else {
281                                 strtoappend += maybeappend;
282                         }
283                 }
284
285                 function pick(img, desc) {
286                         if (img) {
287                                 if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
288                                 if(length == 0) length = 1;
289                                 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
290                                 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
291                                 insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
292                         }
293                         return false;
294                 }
295
296                 function image_selector() {
297                         tb_remove();
298                         desc = jQuery('#this_photo_description').val();
299                         src = jQuery('#this_photo').val();
300                         pick(src, desc);
301                         jQuery('#extra-fields').hide();
302                         jQuery('#extra-fields').html('');
303                         return false;
304                 }
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>');
306                         jQuery('#img_container').html(strtoappend);
307                 <?php break;
308 }
309 die;
310 }
311
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' );
324         wp_enqueue_script( 'post' );
325         wp_enqueue_script( 'editor' );
326 ?>
327 <script type="text/javascript">
328 //<![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();}}};
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() ?>'};
331 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this';
332 var photostorage = false;
333 //]]>
334 </script>
335
336 <?php
337         do_action('admin_print_styles');
338         do_action('admin_print_scripts');
339         do_action('admin_head');
340
341         if ( user_can_richedit() )
342                 wp_tiny_mce( true, array( 'height' => '370' ) );
343 ?>
344         <script type="text/javascript">
345         function insert_plain_editor(text) {
346                 edCanvas = document.getElementById('content');
347                 edInsertContent(edCanvas, text);
348         }
349         function set_editor(text) {
350                 if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
351                 if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
352         }
353         function insert_editor(text) {
354                 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
355                         tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
356                 } else {
357                         insert_plain_editor(decodeURI(text));
358                 }
359         }
360         function append_editor(text) {
361                 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
362                         tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
363                         tinyMCE.execCommand('mceCleanup');
364                 } else {
365                         insert_plain_editor(text);
366                 }
367         }
368
369         function show(tab_name) {
370                 jQuery('#extra-fields').html('');
371                 switch(tab_name) {
372                         case 'video' :
373                                 jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
374                                         <?php
375                                         $content = '';
376                                         if ( preg_match("/youtube\.com\/watch/i", $url) ) {
377                                                 list($domain, $video_id) = split("v=", $url);
378                                                 $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>';
380
381                                         } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
382                                                 list($domain, $video_id) = split(".com/", $url);
383                                                 $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>';
385
386                                                 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>';
388
389                                         } elseif ( strpos( $selection, '<object' ) !== false ) {
390                                                 $content = $selection;
391                                         }
392                                         ?>
393                                         jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
394                                 });
395                                 jQuery('#extra-fields').show();
396                                 return false;
397                                 break;
398                         case 'photo' :
399                                 function setup_photo_actions() {
400                                         jQuery('.close').click(function() {
401                                                 jQuery('#extra-fields').hide();
402                                                 jQuery('#extra-fields').html('');
403                                         });
404                                         jQuery('.refresh').click(function() {
405                                                 photostorage = false;
406                                                 show('photo');
407                                         });
408                                         jQuery('#photo-add-url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
409                                         tb_init('#extra-fields .thickbox');
410                                         jQuery('#waiting').hide();
411                                         jQuery('#extra-fields').show();
412                                 }
413                                 jQuery('#extra-fields').before('<div id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></div>');
414                                 
415                                 if(photostorage == false) {
416                                         jQuery.ajax({
417                                                 type: "GET",
418                                                 cache : false,
419                                                 url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
420                                                 data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
421                                                 dataType : "script",
422                                                 success : function(data) {
423                                                         eval(data);
424                                                         photostorage = jQuery('#extra-fields').html();
425                                                         setup_photo_actions();
426                                                 }
427                                         });
428                                 } else {
429                                         jQuery('#extra-fields').html(photostorage);
430                                         setup_photo_actions();
431                                 }
432                                 return false;
433                                 break;
434                 }
435         }
436         jQuery(document).ready(function($) {
437                 //resize screen
438                 window.resizeTo(720,540);
439                 // set button actions
440         jQuery('#photo_button').click(function() { show('photo'); return false; });
441                 jQuery('#video_button').click(function() { show('video'); return false; });
442                 // auto select
443                 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
444                         show('video');
445                 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
446                         show('video');
447                 <?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
448                         show('photo');
449                 <?php } ?>
450                 jQuery('#title').unbind();
451                 jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
452
453                 $('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
454                         $(this).siblings('.inside').toggle();
455                 });
456         });
457 </script>
458 </head>
459 <body class="press-this wp-admin">
460 <div id="wphead"></div>
461 <form action="press-this.php?action=post" method="post">
462 <div id="poststuff" class="metabox-holder">
463         <div id="side-info-column">
464                 <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') ?>
468                         <input type="hidden" name="post_type" id="post_type" value="text"/>
469                         <input type="hidden" name="autosave" id="autosave" />
470                         <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" />
472
473                         <!-- This div holds the photo metadata -->
474                         <div class="photolist"></div>
475
476                         <div id="submitdiv" class="stuffbox">
477                                 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
478                                         <br/>
479                                 </div>
480                                 <h3><?php _e('Publish') ?></h3>
481                                 <div class="inside">
482                                         <p>
483                                                 <input class="button" type="submit" name="draft" value="<?php esc_attr_e('Save Draft') ?>" id="save" />
484                                                 <?php if ( current_user_can('publish_posts') ) { ?>
485                                                         <input class="button-primary" type="submit" name="publish" value="<?php esc_attr_e('Publish') ?>" id="publish" />
486                                                 <?php } else { ?>
487                                                         <br /><br /><input class="button-primary" type="submit" name="review" value="<?php esc_attr_e('Submit for Review') ?>" id="review" />
488                                                 <?php } ?>
489                                                 <img src="images/wpspin_light.gif" alt="" id="saving" style="display:none;" />
490                                         </p>
491                                 </div>
492                         </div>
493
494                         <div id="categorydiv" class="stuffbox">
495                                 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
496                                         <br/>
497                                 </div>
498                                 <h3><?php _e('Categories') ?></h3>
499                                 <div class="inside">
500
501                                         <div id="categories-all" class="tabs-panel">
502
503                                                 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
504                                                         <?php wp_category_checklist($post_ID, false) ?>
505                                                 </ul>
506                                         </div>
507
508                                         <div id="category-adder" class="wp-hidden-children">
509                                                 <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
510                                                 <p id="category-add" class="wp-hidden-child">
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"/>
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>
518                                 </div>
519                         </div>
520
521                         <div id="tagsdiv-post_tag" class="stuffbox" >
522                                 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
523                                         <br/>
524                                 </div>
525                                 <h3><span><?php _e('Post Tags'); ?></span></h3>
526                                 <div class="inside">
527                                         <div class="tagsdiv" id="post_tag">
528                                                 <p class="jaxtag">
529                                                         <label class="screen-reader-text" for="newtag"><?php _e('Post Tags'); ?></label>
530                                                         <input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
531                                                         <div class="ajaxtag">
532                                                                 <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" />
534                                                         </div>
535                                                 </p>
536                                                 <div class="tagchecklist"></div>
537                                         </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>
539                                 </div>
540                         </div>
541                 </div>
542         </div>
543         <div class="posting">
544                 <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
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>
546                 <?php } ?>
547
548                 <div id="titlediv">
549                         <div class="titlewrap">
550                                 <input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
551                         </div>
552                 </div>
553
554                 <div id="extra-fields" style="display: none"></div>
555
556                 <div class="postdivrich">
557                         <ul id="actions" class="actions">
558
559                                 <li id="photo_button">
560                                         Add: <?php if ( current_user_can('upload_files') ) { ?><a title="<?php _e('Insert an Image'); ?>" href="#">
561 <img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
562                                         <?php } ?>
563                                 </li>
564                                 <li id="video_button">
565                                         <a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
566                                 </li>
567                                 <?php if( user_can_richedit() ) { ?>
568                                 <li id="switcher">
569                                         <?php wp_print_scripts( 'quicktags' ); ?>
570                                         <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
571                                         <a id="edButtonHTML" onclick="switchEditors.go('content', 'html');"><?php _e('HTML'); ?></a>
572                                         <a id="edButtonPreview" class="active" onclick="switchEditors.go('content', 'tinymce');"><?php _e('Visual'); ?></a>
573                                         <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('content')" /></div>
574                                 </li>
575                                 <?php } ?>
576                         </ul>
577                         <div id="quicktags"></div>
578                         <div class="editor-container">
579                                 <textarea name="content" id="content" style="width:100%;" class="theEditor" rows="15"><?php
580                                         if ( $selection )
581                                                 echo wp_richedit_pre($selection);
582                                         if ( $url ) {
583                                                 echo '<p>';
584                                                 if ( $selection )
585                                                         _e('via ');
586                                                 printf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) );
587                                         }
588                                 ?></textarea>
589                         </div>
590                 </div>
591         </div>
592 </div>
593 </form>
594 <?php do_action('admin_print_footer_scripts'); ?>
595 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
596 </body>
597 </html>