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