author | Anthony Ly <anthonyly.com@gmail.com> |
Wed, 19 Dec 2012 17:46:52 -0800 | |
changeset 204 | 09a1c134465b |
parent 194 | 32102edaa81b |
permissions | -rw-r--r-- |
136 | 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 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
12 |
if ( ! isset( $_GET['inline'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
13 |
define( 'IFRAME_REQUEST' , true ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
14 |
|
136 | 15 |
/** Load WordPress Administration Bootstrap */ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
16 |
require_once('./admin.php'); |
136 | 17 |
|
18 |
if (!current_user_can('upload_files')) |
|
19 |
wp_die(__('You do not have permission to upload files.')); |
|
20 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
21 |
wp_enqueue_script('plupload-handlers'); |
136 | 22 |
wp_enqueue_script('image-edit'); |
23 |
wp_enqueue_script('set-post-thumbnail' ); |
|
24 |
wp_enqueue_style('imgareaselect'); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
25 |
wp_enqueue_script( 'media-gallery' ); |
136 | 26 |
|
27 |
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); |
|
28 |
||
29 |
// IDs should be integers |
|
30 |
$ID = isset($ID) ? (int) $ID : 0; |
|
31 |
$post_id = isset($post_id)? (int) $post_id : 0; |
|
32 |
||
33 |
// Require an ID for the edit screen |
|
34 |
if ( isset($action) && $action == 'edit' && !$ID ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
35 |
wp_die( __( 'Cheatin’ uh?' ) ); |
136 | 36 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
37 |
if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
38 |
wp_die( __( 'Cheatin’ uh?' ) ); |
136 | 39 |
|
40 |
// upload type: image, video, file, ..? |
|
41 |
if ( isset($_GET['type']) ) |
|
42 |
$type = strval($_GET['type']); |
|
43 |
else |
|
44 |
$type = apply_filters('media_upload_default_type', 'file'); |
|
45 |
||
46 |
// tab: gallery, library, or type-specific |
|
47 |
if ( isset($_GET['tab']) ) |
|
48 |
$tab = strval($_GET['tab']); |
|
49 |
else |
|
50 |
$tab = apply_filters('media_upload_default_tab', 'type'); |
|
51 |
||
52 |
$body_id = 'media-upload'; |
|
53 |
||
54 |
// let the action code decide how to handle the request |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
55 |
if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) ) |
136 | 56 |
do_action("media_upload_$type"); |
57 |
else |
|
58 |
do_action("media_upload_$tab"); |