wp/wp-admin/media-new.php
author ymh <ymh.work@gmail.com>
Tue, 22 Oct 2019 16:11:46 +0200
changeset 15 3d4e9c994f10
parent 9 177826044cd9
child 16 a86126ab1dd4
permissions -rw-r--r--
Upgrade jquery-ui in in-motion theme version from 1.8.14 to 1.8.22 to avoid 'a.curCSS is not a function' errors in console that caused problems with circles and navigation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Manage media uploaded file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * There are many filters in here for media. Plugins can extend functionality
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * by hooking into the filters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * @subpackage Administration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
/** Load WordPress Administration Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    15
if ( ! current_user_can( 'upload_files' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    16
	wp_die( __( 'Sorry, you are not allowed to upload files.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    17
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    19
wp_enqueue_script( 'plupload-handlers' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
$post_id = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
if ( isset( $_REQUEST['post_id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	$post_id = absint( $_REQUEST['post_id'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    24
	if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
		$post_id = 0;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    26
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
if ( $_POST ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    30
	if ( isset( $_POST['html-upload'] ) && ! empty( $_FILES ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    31
		check_admin_referer( 'media-form' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
		// Upload File button was clicked
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    33
		$upload_id = media_handle_upload( 'async-upload', $post_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    34
		if ( is_wp_error( $upload_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    35
			wp_die( $upload_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    36
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    38
	wp_redirect( admin_url( 'upload.php' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
	exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    42
$title       = __( 'Upload New Media' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
$parent_file = 'upload.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    45
get_current_screen()->add_help_tab(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    46
	array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    47
		'id'      => 'overview',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    48
		'title'   => __( 'Overview' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    49
		'content' =>
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    50
				 '<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    51
				 '<ul>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    52
					 '<li>' . __( '<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.' ) . '</li>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    53
					 '<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    54
					 '<li>' . __( 'Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.' ) . '</li>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    55
				 '</ul>',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    56
	)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    57
);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
get_current_screen()->set_help_sidebar(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    59
	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    60
	'<p>' . __( '<a href="https://codex.wordpress.org/Media_Add_New_Screen">Documentation on Uploading Media Files</a>' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    61
	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
require_once( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
$form_class = 'media-upload-form type-form validate';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    68
if ( get_user_setting( 'uploader' ) || isset( $_GET['browser-uploader'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	$form_class .= ' html-uploader';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    70
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
<div class="wrap">
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    73
	<h1><?php echo esc_html( $title ); ?></h1>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    75
	<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">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
	<?php media_upload_form(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
	<script type="text/javascript">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
	var post_id = <?php echo $post_id; ?>, shortform = 3;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
	</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    83
	<?php wp_nonce_field( 'media-form' ); ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	<div id="media-items" class="hide-if-no-js"></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
include( ABSPATH . 'wp-admin/admin-footer.php' );