wp/wp-admin/media-upload.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    28 
    28 
    29 // IDs should be integers
    29 // IDs should be integers
    30 $ID = isset($ID) ? (int) $ID : 0;
    30 $ID = isset($ID) ? (int) $ID : 0;
    31 $post_id = isset($post_id)? (int) $post_id : 0;
    31 $post_id = isset($post_id)? (int) $post_id : 0;
    32 
    32 
    33 // Require an ID for the edit screen
    33 // Require an ID for the edit screen.
    34 if ( isset($action) && $action == 'edit' && !$ID )
    34 if ( isset($action) && $action == 'edit' && !$ID ) {
    35 	wp_die( __( 'Cheatin’ uh?' ) );
    35 	wp_die( __( 'Cheatin’ uh?' ), 403 );
       
    36 }
    36 
    37 
    37 	if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
    38 if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) ) {
    38 		wp_die( __( 'Cheatin’ uh?' ) );
    39 	wp_die( __( 'Cheatin’ uh?' ), 403 );
       
    40 }
    39 
    41 
    40 	// upload type: image, video, file, ..?
    42 // Upload type: image, video, file, ..?
    41 	if ( isset($_GET['type']) )
    43 if ( isset($_GET['type']) ) {
    42 		$type = strval($_GET['type']);
    44 	$type = strval($_GET['type']);
    43 	else
    45 } else {
    44 		$type = apply_filters('media_upload_default_type', 'file');
    46 	/**
       
    47 	 * Filter the default media upload type in the legacy (pre-3.5.0) media popup.
       
    48 	 *
       
    49 	 * @since 2.5.0
       
    50 	 *
       
    51 	 * @param string $type The default media upload type. Possible values include
       
    52 	 *                     'image', 'audio', 'video', 'file', etc. Default 'file'.
       
    53 	 */
       
    54 	$type = apply_filters( 'media_upload_default_type', 'file' );
       
    55 }
    45 
    56 
    46 	// tab: gallery, library, or type-specific
    57 // Tab: gallery, library, or type-specific.
    47 	if ( isset($_GET['tab']) )
    58 if ( isset($_GET['tab']) ) {
    48 		$tab = strval($_GET['tab']);
    59 	$tab = strval($_GET['tab']);
    49 	else
    60 } else {
    50 		$tab = apply_filters('media_upload_default_tab', 'type');
    61 	/**
       
    62 	 * Filter the default tab in the legacy (pre-3.5.0) media popup.
       
    63 	 *
       
    64 	 * @since 2.5.0
       
    65 	 *
       
    66 	 * @param string $type The default media popup tab. Default 'type' (From Computer).
       
    67 	 */
       
    68 	$tab = apply_filters( 'media_upload_default_tab', 'type' );
       
    69 }
    51 
    70 
    52 	$body_id = 'media-upload';
    71 $body_id = 'media-upload';
    53 
    72 
    54 	// let the action code decide how to handle the request
    73 // Let the action code decide how to handle the request.
    55 	if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) )
    74 if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) ) {
    56 		do_action("media_upload_$type");
    75 	/**
    57 	else
    76 	 * Fires inside specific upload-type views in the legacy (pre-3.5.0)
    58 		do_action("media_upload_$tab");
    77 	 * media popup based on the current tab.
       
    78 	 *
       
    79 	 * The dynamic portion of the hook name, `$type`, refers to the specific
       
    80 	 * media upload type. Possible values include 'image', 'audio', 'video',
       
    81 	 * 'file', etc.
       
    82 	 *
       
    83 	 * The hook only fires if the current `$tab` is 'type' (From Computer),
       
    84 	 * 'type_url' (From URL), or, if the tab does not exist (i.e., has not
       
    85 	 * been registered via the {@see 'media_upload_tabs'} filter.
       
    86 	 *
       
    87 	 * @since 2.5.0
       
    88 	 */
       
    89 	do_action( "media_upload_$type" );
       
    90 } else {
       
    91 	/**
       
    92 	 * Fires inside limited and specific upload-tab views in the legacy
       
    93 	 * (pre-3.5.0) media popup.
       
    94 	 *
       
    95 	 * The dynamic portion of the hook name, `$tab`, refers to the specific
       
    96 	 * media upload tab. Possible values include 'library' (Media Library),
       
    97 	 * or any custom tab registered via the {@see 'media_upload_tabs'} filter.
       
    98 	 *
       
    99 	 * @since 2.5.0
       
   100 	 */
       
   101 	do_action( "media_upload_$tab" );
       
   102 }
       
   103