PageRenderTime 46ms CodeModel.GetById 5ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/wp-admin/media-new.php

https://bitbucket.org/dkrzos/phc
PHP | 85 lines | 60 code | 14 blank | 11 comment | 10 complexity | deffdbbfcb7875a8b0552c781d0f88b4 MD5 | raw file
Possible License(s): GPL-2.0
  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. $post_id = 0;
  17. if ( isset( $_REQUEST['post_id'] ) ) {
  18. $post_id = absint( $_REQUEST['post_id'] );
  19. if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) )
  20. $post_id = 0;
  21. }
  22. if ( $_POST ) {
  23. $location = 'upload.php';
  24. if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
  25. check_admin_referer('media-form');
  26. // Upload File button was clicked
  27. $id = media_handle_upload( 'async-upload', $post_id );
  28. if ( is_wp_error( $id ) )
  29. $location .= '?message=3';
  30. }
  31. wp_redirect( admin_url( $location ) );
  32. exit;
  33. }
  34. $title = __('Upload New Media');
  35. $parent_file = 'upload.php';
  36. get_current_screen()->add_help_tab( array(
  37. 'id' => 'overview',
  38. 'title' => __('Overview'),
  39. 'content' =>
  40. '<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>' .
  41. '<ul>' .
  42. '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
  43. '<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>' .
  44. '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
  45. '</ul>'
  46. ) );
  47. get_current_screen()->set_help_sidebar(
  48. '<p><strong>' . __('For more information:') . '</strong></p>' .
  49. '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
  50. '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
  51. );
  52. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  53. $form_class = 'media-upload-form type-form validate';
  54. if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) )
  55. $form_class .= ' html-uploader';
  56. ?>
  57. <div class="wrap">
  58. <?php screen_icon(); ?>
  59. <h2><?php echo esc_html( $title ); ?></h2>
  60. <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo $form_class; ?>" id="file-form">
  61. <?php media_upload_form(); ?>
  62. <script type="text/javascript">
  63. var post_id = <?php echo $post_id; ?>, shortform = 3;
  64. </script>
  65. <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
  66. <?php wp_nonce_field('media-form'); ?>
  67. <div id="media-items" class="hide-if-no-js"></div>
  68. </form>
  69. </div>
  70. <?php
  71. include( ABSPATH . 'wp-admin/admin-footer.php' );