Changeset 18617
- Timestamp:
- 08/28/2011 08:42:07 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-upgrader.php
r18616 r18617 1435 1435 var $package; 1436 1436 var $filename; 1437 var $id = 0; 1437 1438 1438 1439 function __construct($form, $urlholder) { 1439 if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )1440 wp_die($uploads['error']);1441 1440 1442 1441 if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) ) 1443 1442 wp_die(__('Please select a file')); 1444 1443 1445 if ( !empty($_FILES) ) 1444 //Handle a newly uploaded file, Else assume its already been uploaded 1445 if ( ! empty($_FILES) ) { 1446 $overrides = array( 'test_form' => false, 'test_type' => false ); 1447 $file = wp_handle_upload( $_FILES[$form], $overrides ); 1448 1449 if ( isset( $file['error'] ) ) 1450 wp_die( $file['error'] ); 1451 1446 1452 $this->filename = $_FILES[$form]['name']; 1447 else if ( isset($_GET[$urlholder]) ) 1453 $this->package = $file['file']; 1454 1455 // Construct the object array 1456 $object = array( 1457 'post_title' => $this->filename, 1458 'post_content' => $file['url'], 1459 'post_mime_type' => $file['type'], 1460 'guid' => $file['url'], 1461 'context' => 'upgrader', 1462 'post_status' => 'private' 1463 ); 1464 1465 // Save the data 1466 $this->id = wp_insert_attachment( $object, $file['file'] ); 1467 1468 // schedule a cleanup for 2 hours from now in case of failed install 1469 wp_schedule_single_event( time() + 7200, 'upgrader_scheduled_cleanup', array( $this->id ) ); 1470 1471 } elseif ( is_numeric( $_GET[$urlholder] ) ) { 1472 // Numeric Package = previously uploaded file, see above. 1473 $this->id = (int) $_GET[$urlholder]; 1474 $attachment = get_post( $this->id ); 1475 if ( empty($attachment) ) 1476 wp_die(__('Please select a file')); 1477 1478 $this->filename = $attachment->post_title; 1479 $this->package = get_attached_file( $attachment->ID ); 1480 } else { 1481 // Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler. 1482 if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) 1483 wp_die( $uploads['error'] ); 1484 1448 1485 $this->filename = $_GET[$urlholder]; 1449 1450 //Handle a newly uploaded file, Else assume its already been uploaded1451 if ( !empty($_FILES) ) {1452 $this->filename = wp_unique_filename( $uploads['basedir'], $this->filename );1453 1486 $this->package = $uploads['basedir'] . '/' . $this->filename; 1454 1455 // Move the file to the uploads dir1456 if ( false === @ move_uploaded_file( $_FILES[$form]['tmp_name'], $this->package) )1457 wp_die( sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path']));1458 } else {1459 $this->package = $uploads['basedir'] . '/' . $this->filename;1460 1487 } 1461 1488 } 1462 1489 1463 1490 function cleanup() { 1464 if ( file_exists($this->package) ) 1465 return @unlink($this->package); 1491 if ( $this->id ) 1492 wp_delete_attachment( $this->id ); 1493 1494 elseif ( file_exists( $this->package ) ) 1495 return @unlink( $this->package ); 1496 1466 1497 return true; 1467 1498 } -
trunk/wp-admin/update.php
r18616 r18617 135 135 $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); 136 136 $nonce = 'plugin-upload'; 137 $url = add_query_arg(array('package' => $file_upload-> filename), 'update.php?action=upload-plugin');137 $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin'); 138 138 $type = 'upload'; //Install plugin type, From Web or an Upload. 139 139 … … 240 240 $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); 241 241 $nonce = 'theme-upload'; 242 $url = add_query_arg(array('package' => $file_upload-> filename), 'update.php?action=upload-theme');242 $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme'); 243 243 $type = 'upload'; //Install plugin type, From Web or an Upload. 244 244 -
trunk/wp-includes/default-filters.php
r18610 r18617 260 260 add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); 261 261 add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' ); 262 add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' ); 262 263 263 264 // Navigation menu actions
Note: See TracChangeset
for help on using the changeset viewer.