69 } |
69 } |
70 |
70 |
71 $this->filename = $_FILES[ $form ]['name']; |
71 $this->filename = $_FILES[ $form ]['name']; |
72 $this->package = $file['file']; |
72 $this->package = $file['file']; |
73 |
73 |
74 // Construct the object array. |
74 // Construct the attachment array. |
75 $object = array( |
75 $attachment = array( |
76 'post_title' => $this->filename, |
76 'post_title' => $this->filename, |
77 'post_content' => $file['url'], |
77 'post_content' => $file['url'], |
78 'post_mime_type' => $file['type'], |
78 'post_mime_type' => $file['type'], |
79 'guid' => $file['url'], |
79 'guid' => $file['url'], |
80 'context' => 'upgrader', |
80 'context' => 'upgrader', |
81 'post_status' => 'private', |
81 'post_status' => 'private', |
82 ); |
82 ); |
83 |
83 |
84 // Save the data. |
84 // Save the data. |
85 $this->id = wp_insert_attachment( $object, $file['file'] ); |
85 $this->id = wp_insert_attachment( $attachment, $file['file'] ); |
86 |
86 |
87 // Schedule a cleanup for 2 hours from now in case of failed installation. |
87 // Schedule a cleanup for 2 hours from now in case of failed installation. |
88 wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) ); |
88 wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) ); |
89 |
89 |
90 } elseif ( is_numeric( $_GET[ $urlholder ] ) ) { |
90 } elseif ( is_numeric( $_GET[ $urlholder ] ) ) { |