2008-01-09 09:14:29 +01:00
|
|
|
<?php
|
2008-08-14 08:30:38 +02:00
|
|
|
/**
|
|
|
|
* Manage media uploaded file.
|
|
|
|
*
|
|
|
|
* There are many filters in here for media. Plugins can extend functionality
|
|
|
|
* by hooking into the filters.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
2010-12-01 20:28:24 +01:00
|
|
|
if ( ! isset( $_GET['inline'] ) )
|
|
|
|
define( 'IFRAME_REQUEST' , true );
|
2010-10-18 19:58:36 +02:00
|
|
|
|
2008-08-14 08:30:38 +02:00
|
|
|
/** Load WordPress Administration Bootstrap */
|
2010-04-18 08:14:45 +02:00
|
|
|
require_once('./admin.php');
|
2008-09-27 10:17:55 +02:00
|
|
|
|
|
|
|
if (!current_user_can('upload_files'))
|
|
|
|
wp_die(__('You do not have permission to upload files.'));
|
|
|
|
|
2011-07-29 10:59:35 +02:00
|
|
|
wp_enqueue_script('plupload-handlers');
|
2009-09-11 00:07:33 +02:00
|
|
|
wp_enqueue_script('image-edit');
|
2009-10-08 00:18:09 +02:00
|
|
|
wp_enqueue_script('set-post-thumbnail' );
|
2009-09-11 00:07:33 +02:00
|
|
|
wp_enqueue_style('imgareaselect');
|
2012-04-05 02:20:28 +02:00
|
|
|
wp_enqueue_script( 'media-gallery' );
|
2008-01-09 09:14:29 +01:00
|
|
|
|
|
|
|
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
|
|
|
|
|
|
|
// IDs should be integers
|
2008-08-14 08:30:38 +02:00
|
|
|
$ID = isset($ID) ? (int) $ID : 0;
|
2008-02-22 18:43:56 +01:00
|
|
|
$post_id = isset($post_id)? (int) $post_id : 0;
|
2008-01-09 09:14:29 +01:00
|
|
|
|
|
|
|
// Require an ID for the edit screen
|
2008-02-22 18:43:56 +01:00
|
|
|
if ( isset($action) && $action == 'edit' && !$ID )
|
2012-03-07 20:00:12 +01:00
|
|
|
wp_die( __( 'Cheatin’ uh?' ) );
|
2008-01-09 09:14:29 +01:00
|
|
|
|
2012-06-10 19:37:49 +02:00
|
|
|
if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
|
|
|
|
wp_die( __( 'Cheatin’ uh?' ) );
|
2008-01-09 09:14:29 +01:00
|
|
|
|
2008-09-27 10:17:55 +02:00
|
|
|
// upload type: image, video, file, ..?
|
|
|
|
if ( isset($_GET['type']) )
|
|
|
|
$type = strval($_GET['type']);
|
|
|
|
else
|
|
|
|
$type = apply_filters('media_upload_default_type', 'file');
|
2008-12-09 19:03:31 +01:00
|
|
|
|
2008-09-27 10:17:55 +02:00
|
|
|
// tab: gallery, library, or type-specific
|
|
|
|
if ( isset($_GET['tab']) )
|
|
|
|
$tab = strval($_GET['tab']);
|
|
|
|
else
|
|
|
|
$tab = apply_filters('media_upload_default_tab', 'type');
|
2008-12-09 19:03:31 +01:00
|
|
|
|
2008-09-27 10:17:55 +02:00
|
|
|
$body_id = 'media-upload';
|
2008-12-09 19:03:31 +01:00
|
|
|
|
2008-09-27 10:17:55 +02:00
|
|
|
// let the action code decide how to handle the request
|
2011-10-01 00:52:29 +02:00
|
|
|
if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) )
|
2008-09-27 10:17:55 +02:00
|
|
|
do_action("media_upload_$type");
|
|
|
|
else
|
|
|
|
do_action("media_upload_$tab");
|