PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/press-this.php

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