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