PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/media-new.php

https://bitbucket.org/abnopanda/wordpress
PHP | 80 lines | 55 code | 14 blank | 11 comment | 7 complexity | 4bcf50d813149ccbb84b9fe63b6aab08 MD5 | raw file
  1. <?php
  2. /**
  3. * Manage media uploaded file.
  4. *
  5. * There are many filters in here for media. Plugins can extend functionality
  6. * by hooking into the filters.
  7. *
  8. * @package WordPress
  9. * @subpackage Administration
  10. */
  11. /** Load WordPress Administration Bootstrap */
  12. require_once('./admin.php');
  13. if (!current_user_can('upload_files'))
  14. wp_die(__('You do not have permission to upload files.'));
  15. wp_enqueue_script('plupload-handlers');
  16. unset( $_REQUEST['post_id'] );
  17. if ( $_POST ) {
  18. $location = 'upload.php';
  19. if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
  20. check_admin_referer('media-form');
  21. // Upload File button was clicked
  22. $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
  23. if ( is_wp_error( $id ) )
  24. $location .= '?message=3';
  25. }
  26. wp_redirect( admin_url( $location ) );
  27. exit;
  28. }
  29. $title = __('Upload New Media');
  30. $parent_file = 'upload.php';
  31. get_current_screen()->add_help_tab( array(
  32. 'id' => 'overview',
  33. 'title' => __('Overview'),
  34. 'content' =>
  35. '<p>' . __('You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share. There are three options for uploading files:') . '</p>' .
  36. '<ul>' .
  37. '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
  38. '<li>' . __('Clicking <strong>Select Files</strong> opens a navigation window showing you files in your operating system. Selecting <strong>Open</strong> after clicking on the file you want activates a progress bar on the uploader screen.') . '</li>' .
  39. '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
  40. '</ul>'
  41. ) );
  42. get_current_screen()->set_help_sidebar(
  43. '<p><strong>' . __('For more information:') . '</strong></p>' .
  44. '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
  45. '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
  46. );
  47. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  48. $form_class = 'media-upload-form wp-upload-form type-form validate';
  49. if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) )
  50. $form_class .= ' html-uploader';
  51. ?>
  52. <div class="wrap">
  53. <?php screen_icon(); ?>
  54. <h2><?php echo esc_html( $title ); ?></h2>
  55. <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo $form_class; ?>" id="file-form">
  56. <?php media_upload_form(); ?>
  57. <script type="text/javascript">
  58. var post_id = 0, shortform = 3;
  59. </script>
  60. <input type="hidden" name="post_id" id="post_id" value="0" />
  61. <?php wp_nonce_field('media-form'); ?>
  62. <div id="media-items" class="hide-if-no-js"></div>
  63. </form>
  64. </div>
  65. <?php
  66. include( ABSPATH . 'wp-admin/admin-footer.php' );