5daa2f9bbd75c6814eac09b70b2dc1a87898d880
[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( dirname( __FILE__ ) . '/admin.php' );
13
14 header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
15
16 if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) )
17         wp_die( __( 'Cheatin&#8217; uh?' ) );
18
19 /**
20  * Press It form handler.
21  *
22  * @since 2.6.0
23  *
24  * @return int Post ID
25  */
26 function press_it() {
27
28         $post = get_default_post_to_edit();
29         $post = get_object_vars($post);
30         $post_ID = $post['ID'] = (int) $_POST['post_id'];
31
32         if ( !current_user_can('edit_post', $post_ID) )
33                 wp_die(__('You are not allowed to edit this post.'));
34
35         $post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : '';
36         $post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : '';
37         $post['post_title'] = isset($_POST['title']) ? $_POST['title'] : '';
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         $post['post_content'] = $content;
56         if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) )
57                 $post['post_status'] = 'publish';
58         elseif ( isset( $_POST['review'] ) )
59                 $post['post_status'] = 'pending';
60         else
61                 $post['post_status'] = 'draft';
62
63         // Error handling for media_sideload.
64         if ( is_wp_error($upload) ) {
65                 wp_delete_post($post_ID);
66                 wp_die($upload);
67         } else {
68                 // Post formats.
69                 if ( isset( $_POST['post_format'] ) ) {
70                         if ( current_theme_supports( 'post-formats', $_POST['post_format'] ) )
71                                 set_post_format( $post_ID, $_POST['post_format'] );
72                         elseif ( '0' == $_POST['post_format'] )
73                                 set_post_format( $post_ID, false );
74                 }
75
76                 $post_ID = wp_update_post($post);
77         }
78
79         return $post_ID;
80 }
81
82 // For submitted posts.
83 if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
84         check_admin_referer('press-this');
85         $posted = $post_ID = press_it();
86 } else {
87         $post = get_default_post_to_edit('post', true);
88         $post_ID = $post->ID;
89 }
90
91 // Set Variables
92 $title = isset( $_GET['t'] ) ? trim( strip_tags( html_entity_decode( wp_unslash( $_GET['t'] ) , ENT_QUOTES) ) ) : '';
93
94 $selection = '';
95 if ( !empty($_GET['s']) ) {
96         $selection = str_replace('&apos;', "'", wp_unslash($_GET['s']));
97         $selection = trim( htmlspecialchars( html_entity_decode($selection, ENT_QUOTES) ) );
98 }
99
100 if ( ! empty($selection) ) {
101         $selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
102         $selection = '<p>' . str_replace('<p></p>', '', $selection) . '</p>';
103 }
104
105 $url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
106 $image = isset($_GET['i']) ? $_GET['i'] : '';
107
108 if ( !empty($_REQUEST['ajax']) ) {
109         switch ($_REQUEST['ajax']) {
110                 case 'video': ?>
111                         <script type="text/javascript">
112                         /* <![CDATA[ */
113                                 jQuery('.select').click(function() {
114                                         append_editor(jQuery('#embed-code').val());
115                                         jQuery('#extra-fields').hide();
116                                         jQuery('#extra-fields').html('');
117                                 });
118                                 jQuery('.close').click(function() {
119                                         jQuery('#extra-fields').hide();
120                                         jQuery('#extra-fields').html('');
121                                 });
122                         /* ]]> */
123                         </script>
124                         <div class="postbox">
125                                 <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
126                                 <div class="inside">
127                                         <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo esc_textarea( $selection ); ?></textarea>
128                                         <p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
129                                 </div>
130                         </div>
131                         <?php break;
132
133                 case 'photo_thickbox': ?>
134                         <script type="text/javascript">
135                                 /* <![CDATA[ */
136                                 jQuery('.cancel').click(function() {
137                                         tb_remove();
138                                 });
139                                 jQuery('.select').click(function() {
140                                         image_selector(this);
141                                 });
142                                 /* ]]> */
143                         </script>
144                         <h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3>
145                         <div class="titlediv">
146                                 <div class="titlewrap">
147                                         <input id="tb_this_photo_description" name="photo_description" class="tb_this_photo_description tbtitle text" type="text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/>
148                                 </div>
149                         </div>
150
151                         <p class="centered">
152                                 <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" class="tb_this_photo" />
153                                 <a href="#" class="select">
154                                         <img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
155                                 </a>
156                         </p>
157
158                         <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
159                         <?php break;
160         case 'photo_images':
161                 /**
162                  * Retrieve all image URLs from given URI.
163                  *
164                  * @since 2.6.0
165                  *
166                  * @param string $uri
167                  * @return string
168                  */
169                 function get_images_from_uri($uri) {
170                         $uri = preg_replace('/\/#.+?$/','', $uri);
171                         if ( preg_match( '/\.(jpe?g|jpe|gif|png)\b/i', $uri ) && !strpos( $uri, 'blogger.com' ) )
172                                 return "'" . esc_attr( html_entity_decode($uri) ) . "'";
173                         $content = wp_remote_fopen($uri);
174                         if ( false === $content )
175                                 return '';
176                         $host = parse_url($uri);
177                         $pattern = '/<img ([^>]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/i';
178                         $content = str_replace(array("\n","\t","\r"), '', $content);
179                         preg_match_all($pattern, $content, $matches);
180                         if ( empty($matches[0]) )
181                                 return '';
182                         $sources = array();
183                         foreach ($matches[3] as $src) {
184
185                                 // If no http in URL.
186                                 if (strpos($src, 'http') === false)
187                                         // If it doesn't have a relative URI.
188                                         if ( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
189                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
190                                         else
191                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
192                                 $sources[] = esc_url($src);
193                         }
194                         return "'" . implode("','", $sources) . "'";
195                 }
196                 $url = wp_kses(urldecode($url), null);
197                 echo 'new Array('.get_images_from_uri($url).')';
198                 break;
199
200         case 'photo_js': ?>
201                 // Gather images and load some default JS.
202                 var last = null
203                 var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
204                 if(photostorage == false) {
205                 var my_src = eval(
206                         jQuery.ajax({
207                                 type: "GET",
208                                 url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
209                                 cache : false,
210                                 async : false,
211                                 data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
212                                 dataType : "script"
213                         }).responseText
214                 );
215                 if(my_src.length == 0) {
216                         var my_src = eval(
217                                 jQuery.ajax({
218                                         type: "GET",
219                                         url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
220                                         cache : false,
221                                         async : false,
222                                         data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
223                                         dataType : "script"
224                                 }).responseText
225                         );
226                         if(my_src.length == 0) {
227                                 strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
228                         }
229                 }
230                 }
231                 for (i = 0; i < my_src.length; i++) {
232                         img = new Image();
233                         img.src = my_src[i];
234                         img_attr = 'id="img' + i + '"';
235                         skip = false;
236
237                         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>';
238
239                         if (img.width && img.height) {
240                                 if (img.width >= 30 && img.height >= 30) {
241                                         aspect = img.width / img.height;
242                                         scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
243
244                                         w = img.width;
245                                         h = img.height;
246
247                                         if (scale < 1) {
248                                                 w = parseInt(img.width * scale);
249                                                 h = parseInt(img.height * scale);
250                                         }
251                                         img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
252                                         strtoappend += maybeappend;
253                                 }
254                         } else {
255                                 strtoappend += maybeappend;
256                         }
257                 }
258
259                 function pick(img, desc) {
260                         if (img) {
261                                 if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
262                                 if(length == 0) length = 1;
263                                 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
264                                 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
265                                 insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
266                         }
267                         return false;
268                 }
269
270                 function image_selector(el) {
271                         var desc, src, parent = jQuery(el).closest('#photo-add-url-div');
272
273                         if ( parent.length ) {
274                                 desc = parent.find('input.tb_this_photo_description').val() || '';
275                                 src = parent.find('input.tb_this_photo').val() || ''
276                         } else {
277                                 desc = jQuery('#tb_this_photo_description').val() || '';
278                                 src = jQuery('#tb_this_photo').val() || ''
279                         }
280
281                         tb_remove();
282                         pick(src, desc);
283                         jQuery('#extra-fields').hide();
284                         jQuery('#extra-fields').html('');
285                         return false;
286                 }
287
288                 jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( 'Add Photos' ); ?> <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="button button-small"><?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>');
289                 jQuery('#img_container').html(strtoappend);
290                 <?php break;
291 }
292 die;
293 }
294
295         wp_enqueue_style( 'colors' );
296         wp_enqueue_script( 'post' );
297         add_thickbox();
298         _wp_admin_html_begin();
299 ?>
300 <title><?php _e('Press This') ?></title>
301 <script type="text/javascript">
302 //<![CDATA[
303 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();}}};
304 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
305 var photostorage = false;
306 //]]>
307 </script>
308
309 <?php
310         /** This action is documented in wp-admin/admin-header.php */
311         do_action( 'admin_enqueue_scripts', 'press-this.php' );
312
313         /**
314          * Fires when styles are printed for the Press This admin page.
315          *
316          * @since 3.7.0
317          */
318         do_action( 'admin_print_styles-press-this.php' );
319
320         /** This action is documented in wp-admin/admin-header.php */
321         do_action( 'admin_print_styles' );
322
323         /**
324          * Fires when scripts are printed for the Press This admin page.
325          *
326          * @since 3.7.0
327          */
328         do_action( 'admin_print_scripts-press-this.php' );
329
330         /** This action is documented in wp-admin/admin-header.php */
331         do_action( 'admin_print_scripts' );
332
333         /**
334          * Fires in the head tag on the Press This admin page.
335          *
336          * @since 3.7.0
337          */
338         do_action( 'admin_head-press-this.php' );
339
340         /** This action is documented in wp-admin/admin-header.php */
341         do_action( 'admin_head' );
342 ?>
343         <script type="text/javascript">
344         var wpActiveEditor = 'content';
345
346         function insert_plain_editor(text) {
347                 if ( typeof(QTags) != 'undefined' )
348                         QTags.insertContent(text);
349         }
350         function set_editor(text) {
351                 if ( '' == text || '<p></p>' == text )
352                         text = '<p><br /></p>';
353
354                 if ( tinyMCE.activeEditor )
355                         tinyMCE.execCommand('mceSetContent', false, text);
356         }
357         function insert_editor(text) {
358                 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
359                         tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
360                 } else {
361                         insert_plain_editor(decodeURI(text));
362                 }
363         }
364         function append_editor(text) {
365                 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
366                         tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
367                 } else {
368                         insert_plain_editor(text);
369                 }
370         }
371
372         function show(tab_name) {
373                 jQuery('#extra-fields').html('');
374                 switch(tab_name) {
375                         case 'video' :
376                                 jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
377                                         <?php
378                                         $content = '';
379                                         if ( preg_match("/youtube\.com\/watch/i", $url) ) {
380                                                 list($domain, $video_id) = explode("v=", $url);
381                                                 $video_id = esc_attr($video_id);
382                                                 $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>';
383
384                                         } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
385                                                 list($domain, $video_id) = explode(".com/", $url);
386                                                 $video_id = esc_attr($video_id);
387                                                 $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>';
388
389                                                 if ( trim($selection) == '' )
390                                                         $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>';
391
392                                         } elseif ( strpos( $selection, '<object' ) !== false ) {
393                                                 $content = $selection;
394                                         }
395                                         ?>
396                                         jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
397                                 });
398                                 jQuery('#extra-fields').show();
399                                 return false;
400                                 break;
401                         case 'photo' :
402                                 function setup_photo_actions() {
403                                         jQuery('.close').click(function() {
404                                                 jQuery('#extra-fields').hide();
405                                                 jQuery('#extra-fields').html('');
406                                         });
407                                         jQuery('.refresh').click(function() {
408                                                 photostorage = false;
409                                                 show('photo');
410                                         });
411                                         jQuery('#photo-add-url').click(function(){
412                                                 var form = jQuery('#photo-add-url-div').clone();
413                                                 jQuery('#img_container').empty().append( form.show() );
414                                         });
415                                         jQuery('#waiting').hide();
416                                         jQuery('#extra-fields').show();
417                                 }
418
419                                 jQuery('#waiting').show();
420                                 if(photostorage == false) {
421                                         jQuery.ajax({
422                                                 type: "GET",
423                                                 cache : false,
424                                                 url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
425                                                 data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
426                                                 dataType : "script",
427                                                 success : function(data) {
428                                                         eval(data);
429                                                         photostorage = jQuery('#extra-fields').html();
430                                                         setup_photo_actions();
431                                                 }
432                                         });
433                                 } else {
434                                         jQuery('#extra-fields').html(photostorage);
435                                         setup_photo_actions();
436                                 }
437                                 return false;
438                                 break;
439                 }
440         }
441         jQuery(document).ready(function($) {
442                 var $contnet = $( '#content' );
443
444                 // Resize screen.
445                 window.resizeTo(760,580);
446
447                 // Set button actions.
448                 jQuery('#photo_button').click(function() { show('photo'); return false; });
449                 jQuery('#video_button').click(function() { show('video'); return false; });
450
451                 // Auto select.
452                 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
453                         show('video');
454                 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
455                         show('video');
456                 <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
457                         show('photo');
458                 <?php } ?>
459                 jQuery('#title').unbind();
460                 jQuery('#publish, #save').click(function() { jQuery('.press-this #publishing-actions .spinner').css('display', 'inline-block'); });
461
462                 $('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
463                         $(this).siblings('.inside').toggle();
464                 });
465
466                 if ( $( '#wp-content-wrap' ).hasClass( 'html-active' ) && window.switchEditors &&
467                         ( tinyMCEPreInit.mceInit.content && tinyMCEPreInit.mceInit.content.wpautop ) ) {
468                         // The Text editor is default, run the initial content through pre_wpautop() to convert the paragraphs
469                         $contnet.text( window.switchEditors.pre_wpautop( $contnet.text() ) );
470                 }
471         });
472 </script>
473 </head>
474 <?php
475 $admin_body_class = ( is_rtl() ) ? 'rtl' : '';
476 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
477 ?>
478 <body class="press-this wp-admin wp-core-ui <?php echo $admin_body_class; ?>">
479 <form action="press-this.php?action=post" method="post">
480 <div id="poststuff" class="metabox-holder">
481         <div id="side-sortables" class="press-this-sidebar">
482                 <div class="sleeve">
483                         <?php wp_nonce_field('press-this') ?>
484                         <input type="hidden" name="post_type" id="post_type" value="text"/>
485                         <input type="hidden" name="autosave" id="autosave" />
486                         <input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
487                         <input type="hidden" id="prev_status" name="prev_status" value="draft" />
488                         <input type="hidden" id="post_id" name="post_id" value="<?php echo (int) $post_ID; ?>" />
489
490                         <!-- This div holds the photo metadata -->
491                         <div class="photolist"></div>
492
493                         <div id="submitdiv" class="postbox">
494                                 <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
495                                 <h3 class="hndle"><?php _e('Press This') ?></h3>
496                                 <div class="inside">
497                                         <p id="publishing-actions">
498                                         <?php
499                                                 submit_button( __( 'Save Draft' ), 'button', 'draft', false, array( 'id' => 'save' ) );
500                                                 if ( current_user_can('publish_posts') ) {
501                                                         submit_button( __( 'Publish' ), 'primary', 'publish', false );
502                                                 } else {
503                                                         echo '<br /><br />';
504                                                         submit_button( __( 'Submit for Review' ), 'primary', 'review', false );
505                                                 } ?>
506                                                 <span class="spinner" style="display: none;"></span>
507                                         </p>
508                                         <?php if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) :
509                                                         $post_formats = get_theme_support( 'post-formats' );
510                                                         if ( is_array( $post_formats[0] ) ) :
511                                                                 $default_format = get_option( 'default_post_format', '0' );
512                                                 ?>
513                                         <p>
514                                                 <label for="post_format"><?php _e( 'Post Format:' ); ?>
515                                                 <select name="post_format" id="post_format">
516                                                         <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
517                                                 <?php foreach ( $post_formats[0] as $format ): ?>
518                                                         <option<?php selected( $default_format, $format ); ?> value="<?php echo esc_attr( $format ); ?>"> <?php echo esc_html( get_post_format_string( $format ) ); ?></option>
519                                                 <?php endforeach; ?>
520                                                 </select></label>
521                                         </p>
522                                         <?php endif; endif; ?>
523                                 </div>
524                         </div>
525
526                         <?php $tax = get_taxonomy( 'category' ); ?>
527                         <div id="categorydiv" class="postbox">
528                                 <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
529                                 <h3 class="hndle"><?php _e('Categories') ?></h3>
530                                 <div class="inside">
531                                 <div id="taxonomy-category" class="categorydiv">
532
533                                         <ul id="category-tabs" class="category-tabs">
534                                                 <li class="tabs"><a href="#category-all"><?php echo $tax->labels->all_items; ?></a></li>
535                                                 <li class="hide-if-no-js"><a href="#category-pop"><?php _e( 'Most Used' ); ?></a></li>
536                                         </ul>
537
538                                         <div id="category-pop" class="tabs-panel" style="display: none;">
539                                                 <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
540                                                         <?php $popular_ids = wp_popular_terms_checklist( 'category' ); ?>
541                                                 </ul>
542                                         </div>
543
544                                         <div id="category-all" class="tabs-panel">
545                                                 <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
546                                                         <?php wp_terms_checklist($post_ID, array( 'taxonomy' => 'category', 'popular_cats' => $popular_ids ) ) ?>
547                                                 </ul>
548                                         </div>
549
550                                         <?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
551                                         <p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
552                                         <?php endif; ?>
553                                         <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
554                                                 <div id="category-adder" class="wp-hidden-children">
555                                                         <h4>
556                                                                 <a id="category-add-toggle" href="#category-add" class="hide-if-no-js">
557                                                                         <?php printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>
558                                                                 </a>
559                                                         </h4>
560                                                         <p id="category-add" class="category-add wp-hidden-child">
561                                                                 <label class="screen-reader-text" for="newcategory"><?php echo $tax->labels->add_new_item; ?></label>
562                                                                 <input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" aria-required="true"/>
563                                                                 <label class="screen-reader-text" for="newcategory_parent">
564                                                                         <?php echo $tax->labels->parent_item_colon; ?>
565                                                                 </label>
566                                                                 <?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;' ) ); ?>
567                                                                 <input type="button" id="category-add-submit" data-wp-lists="add:categorychecklist:category-add" class="button category-add-submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" />
568                                                                 <?php wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); ?>
569                                                                 <span id="category-ajax-response"></span>
570                                                         </p>
571                                                 </div>
572                                         <?php endif; ?>
573                                 </div>
574                                 </div>
575                         </div>
576
577                         <div id="tagsdiv-post_tag" class="postbox">
578                                 <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
579                                 <h3><span><?php _e('Tags'); ?></span></h3>
580                                 <div class="inside">
581                                         <div class="tagsdiv" id="post_tag">
582                                                 <div class="jaxtag">
583                                                         <label class="screen-reader-text" for="newtag"><?php _e('Tags'); ?></label>
584                                                         <input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
585                                                         <div class="ajaxtag">
586                                                                 <input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
587                                                                 <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" />
588                                                         </div>
589                                                 </div>
590                                                 <div class="tagchecklist"></div>
591                                         </div>
592                                         <p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags'); ?></a></p>
593                                 </div>
594                         </div>
595                 </div>
596         </div>
597         <div class="posting">
598
599                 <div id="wphead">
600                         <h1 id="site-heading">
601                                 <a href="<?php echo get_option('home'); ?>/" target="_blank">
602                                         <span id="site-title"><?php bloginfo('name'); ?></span>
603                                 </a>
604                         </h1>
605                 </div>
606
607                 <?php
608                 if ( isset($posted) && intval($posted) ) {
609                         $post_ID = intval($posted); ?>
610                         <div id="message" class="updated">
611                         <p><strong><?php _e('Your post has been saved.'); ?></strong>
612                         <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink($post_ID); ?>"><?php _e('View post'); ?></a>
613                         | <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit Post'); ?></a>
614                         | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p>
615                         </div>
616                 <?php } ?>
617
618                 <div id="titlediv">
619                         <div class="titlewrap">
620                                 <input name="title" id="title" class="text" type="text" value="<?php echo esc_attr($title);?>"/>
621                         </div>
622                 </div>
623
624                 <div id="waiting" style="display: none"><span class="spinner"></span> <span><?php esc_html_e( 'Loading&hellip;' ); ?></span></div>
625
626                 <div id="extra-fields" style="display: none"></div>
627
628                 <div class="postdivrich">
629                 <?php
630
631                 $editor_settings = array(
632                         'teeny' => true,
633                         'textarea_rows' => '15'
634                 );
635
636                 $content = '';
637                 if ( $selection )
638                         $content .= $selection;
639
640                 if ( $url ) {
641                         $content .= '<p>';
642
643                         if ( $selection )
644                                 $content .= __('via ');
645
646                         $content .= sprintf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) );
647                 }
648
649                 remove_action( 'media_buttons', 'media_buttons' );
650                 add_action( 'media_buttons', 'press_this_media_buttons' );
651                 function press_this_media_buttons() {
652                         _e( 'Add:' );
653
654                         if ( current_user_can('upload_files') ) {
655                                 ?>
656                                 <a id="photo_button" title="<?php esc_attr_e('Insert an Image'); ?>" href="#">
657                                 <img alt="<?php esc_attr_e('Insert an Image'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-image.gif?ver=20100531' ) ); ?>"/></a>
658                                 <?php
659                         }
660                         ?>
661                         <a id="video_button" title="<?php esc_attr_e('Embed a Video'); ?>" href="#"><img alt="<?php esc_attr_e('Embed a Video'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-video.gif?ver=20100531' ) ); ?>"/></a>
662                         <?php
663                 }
664
665                 wp_editor( $content, 'content', $editor_settings );
666
667                 ?>
668                 </div>
669         </div>
670 </div>
671 </form>
672 <div id="photo-add-url-div" style="display:none;">
673         <table><tr>
674         <td><label for="this_photo"><?php _e('URL') ?></label></td>
675         <td><input type="text" id="this_photo" name="this_photo" class="tb_this_photo text" onkeypress="if(event.keyCode==13) image_selector(this);" /></td>
676         </tr><tr>
677         <td><label for="this_photo_description"><?php _e('Description') ?></label></td>
678         <td><input type="text" id="this_photo_description" name="photo_description" class="tb_this_photo_description text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/></td>
679         </tr><tr>
680         <td><input type="button" class="button" onclick="image_selector(this)" value="<?php esc_attr_e('Insert Image'); ?>" /></td>
681         </tr></table>
682 </div>
683 <?php
684 /** This action is documented in wp-admin/admin-footer.php */
685 do_action( 'admin_footer' );
686 /** This action is documented in wp-admin/admin-footer.php */
687 do_action( 'admin_print_footer_scripts' );
688 ?>
689 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
690 </body>
691 </html>