From ea9d389751d72346a98b1b5af8fe41afa58711fc Mon Sep 17 00:00:00 2001 From: rob1n Date: Tue, 24 Apr 2007 23:27:20 +0000 Subject: [PATCH] Add unfiltered_upload cap, and allow for admins. Props Nazgul. fixes #4136 git-svn-id: http://svn.automattic.com/wordpress/trunk@5303 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 2 +- wp-admin/upgrade-functions.php | 12 ++++++++++++ wp-admin/upgrade-schema.php | 9 +++++++++ wp-includes/version.php | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index be07a73c9d..750ff16a9d 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1948,7 +1948,7 @@ function wp_handle_upload( &$file, $overrides = false ) { return $upload_error_handler( $file, __( 'Specified file failed upload test.' )); // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. - if ( $test_type ) { + if ( $test_type && !current_user_can( 'unfiltered_upload' ) ) { $wp_filetype = wp_check_filetype( $file['name'], $mimes ); extract( $wp_filetype ); diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 168a7c3c2d..c403340e07 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -184,6 +184,10 @@ function upgrade_all() { if ( $wp_current_db_version < 4351 ) upgrade_old_slugs(); + + if ( $wp_current_db_version < 5200 ) { + upgrade_230(); + } $wp_rewrite->flush_rules(); @@ -565,6 +569,14 @@ function upgrade_210() { } } +function upgrade_230() { + global $wp_current_db_version; + + if ( $wp_current_db_version < 5200 ) { + populate_roles_230(); + } +} + function upgrade_old_slugs() { // upgrade people who were using the Redirect Old Slugs plugin global $wpdb; diff --git a/wp-admin/upgrade-schema.php b/wp-admin/upgrade-schema.php index c6ee94fba9..d3b4c6dc96 100644 --- a/wp-admin/upgrade-schema.php +++ b/wp-admin/upgrade-schema.php @@ -262,6 +262,7 @@ function populate_options() { function populate_roles() { populate_roles_160(); populate_roles_210(); + populate_roles_230(); } function populate_roles_160() { @@ -395,4 +396,12 @@ function populate_roles_210() { } } +function populate_roles_230() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'unfiltered_upload' ); + } +} + ?> \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index a85b00d9c5..7a0d5d34a7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -3,6 +3,6 @@ // This holds the version number in a separate file so we can bump it without cluttering the SVN $wp_version = '2.3-alpha'; -$wp_db_version = 5183; +$wp_db_version = 5200; ?>