[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-admin/ -> media-new.php (source)

   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  
  12  /** Load WordPress Administration Bootstrap */
  13  require_once( dirname( __FILE__ ) . '/admin.php' );
  14  
  15  if (!current_user_can('upload_files'))
  16      wp_die(__('You do not have permission to upload files.'));
  17  
  18  wp_enqueue_script('plupload-handlers');
  19  
  20  $post_id = 0;
  21  if ( isset( $_REQUEST['post_id'] ) ) {
  22      $post_id = absint( $_REQUEST['post_id'] );
  23      if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) )
  24          $post_id = 0;
  25  }
  26  
  27  if ( $_POST ) {
  28      $location = 'upload.php';
  29      if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
  30          check_admin_referer('media-form');
  31          // Upload File button was clicked
  32          $id = media_handle_upload( 'async-upload', $post_id );
  33          if ( is_wp_error( $id ) )
  34              $location .= '?message=3';
  35      }
  36      wp_redirect( admin_url( $location ) );
  37      exit;
  38  }
  39  
  40  $title = __('Upload New Media');
  41  $parent_file = 'upload.php';
  42  
  43  get_current_screen()->add_help_tab( array(
  44  'id'        => 'overview',
  45  'title'        => __('Overview'),
  46  'content'    =>
  47      '<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>' .
  48      '<ul>' .
  49          '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
  50          '<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>' .
  51          '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
  52      '</ul>'
  53  ) );
  54  get_current_screen()->set_help_sidebar(
  55      '<p><strong>' . __('For more information:') . '</strong></p>' .
  56      '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
  57      '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
  58  );
  59  
  60  require_once ( ABSPATH . 'wp-admin/admin-header.php' );
  61  
  62  $form_class = 'media-upload-form type-form validate';
  63  
  64  if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) )
  65      $form_class .= ' html-uploader';
  66  ?>
  67  <div class="wrap">
  68      <h2><?php echo esc_html( $title ); ?></h2>
  69  
  70      <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo esc_attr( $form_class ); ?>" id="file-form">
  71  
  72      <?php media_upload_form(); ?>
  73  
  74      <script type="text/javascript">
  75      var post_id = <?php echo $post_id; ?>, shortform = 3;
  76      </script>
  77      <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
  78      <?php wp_nonce_field('media-form'); ?>
  79      <div id="media-items" class="hide-if-no-js"></div>
  80      </form>
  81  </div>
  82  
  83  <?php
  84  include ( ABSPATH . 'wp-admin/admin-footer.php' );


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu