wp/wp-admin/update.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
   105 
   105 
   106 		if ( ! current_user_can( 'install_plugins' ) ) {
   106 		if ( ! current_user_can( 'install_plugins' ) ) {
   107 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   107 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   108 		}
   108 		}
   109 
   109 
   110 		include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // For plugins_api().
   110 		require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // For plugins_api().
   111 
   111 
   112 		check_admin_referer( 'install-plugin_' . $plugin );
   112 		check_admin_referer( 'install-plugin_' . $plugin );
   113 		$api = plugins_api(
   113 		$api = plugins_api(
   114 			'plugin_information',
   114 			'plugin_information',
   115 			array(
   115 			array(
   152 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   152 			wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) );
   153 		}
   153 		}
   154 
   154 
   155 		check_admin_referer( 'plugin-upload' );
   155 		check_admin_referer( 'plugin-upload' );
   156 
   156 
       
   157 		if ( isset( $_FILES['pluginzip']['name'] ) && ! str_ends_with( strtolower( $_FILES['pluginzip']['name'] ), '.zip' ) ) {
       
   158 			wp_die( __( 'Only .zip archives may be uploaded.' ) );
       
   159 		}
       
   160 
   157 		$file_upload = new File_Upload_Upgrader( 'pluginzip', 'package' );
   161 		$file_upload = new File_Upload_Upgrader( 'pluginzip', 'package' );
   158 
   162 
   159 		// Used in the HTML title tag.
   163 		// Used in the HTML title tag.
   160 		$title        = __( 'Upload Plugin' );
   164 		$title        = __( 'Upload Plugin' );
   161 		$parent_file  = 'plugins.php';
   165 		$parent_file  = 'plugins.php';
   256 
   260 
   257 		if ( ! current_user_can( 'install_themes' ) ) {
   261 		if ( ! current_user_can( 'install_themes' ) ) {
   258 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   262 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   259 		}
   263 		}
   260 
   264 
   261 		include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // For themes_api().
   265 		require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // For themes_api().
   262 
   266 
   263 		check_admin_referer( 'install-theme_' . $theme );
   267 		check_admin_referer( 'install-theme_' . $theme );
   264 		$api = themes_api(
   268 		$api = themes_api(
   265 			'theme_information',
   269 			'theme_information',
   266 			array(
   270 			array(
   299 		if ( ! current_user_can( 'upload_themes' ) ) {
   303 		if ( ! current_user_can( 'upload_themes' ) ) {
   300 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   304 			wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
   301 		}
   305 		}
   302 
   306 
   303 		check_admin_referer( 'theme-upload' );
   307 		check_admin_referer( 'theme-upload' );
       
   308 
       
   309 		if ( isset( $_FILES['themezip']['name'] ) && ! str_ends_with( strtolower( $_FILES['themezip']['name'] ), '.zip' ) ) {
       
   310 			wp_die( __( 'Only .zip archives may be uploaded.' ) );
       
   311 		}
   304 
   312 
   305 		$file_upload = new File_Upload_Upgrader( 'themezip', 'package' );
   313 		$file_upload = new File_Upload_Upgrader( 'themezip', 'package' );
   306 
   314 
   307 		// Used in the HTML title tag.
   315 		// Used in the HTML title tag.
   308 		$title        = __( 'Upload Theme' );
   316 		$title        = __( 'Upload Theme' );