PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-admin/press-this.php

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