PluginProbe
SpiceBox / 0.3.5
SpiceBox v0.3.5
trunk 0.2.2 0.2.3 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 0.3.8 0.3.9.1 0.3.9.2 0.4 0.5 0.6 0.7 1.0 All 76 releases
spicebox / inc / innofit / default-pages / upload-media.php

upload-media.php in SpiceBox 0.3.5, at inc/innofit/default-pages/upload-media.php

31 lines 947 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $ImagePath = SPICEB_PLUGIN_URL .'inc/innofit/images';
3
4 $images = array(
5 $ImagePath. '/logo.png',
6 );
7
8 foreach($images as $name) {
9 $filename = basename($name);
10 $upload_file = wp_upload_bits($filename, null, file_get_contents($name));
11 if (!$upload_file['error']) {
12 $wp_filetype = wp_check_filetype($filename, null );
13 $attachment = array(
14 'post_mime_type' => $wp_filetype['type'],
15 'post_parent' => $parent_post_id,
16 'post_title' => preg_replace('/\.[^.]+$/', '', $filename),
17 'post_status' => 'inherit'
18 );
19 $ImageId[] = $attachment_id = wp_insert_attachment( $attachment, $upload_file['file'], $parent_post_id );
20
21 if (!is_wp_error($attachment_id)) {
22 require_once(ABSPATH . "wp-admin" . '/includes/image.php');
23 $attachment_data = wp_generate_attachment_metadata( $attachment_id, $upload_file['file'] );
24 wp_update_attachment_metadata( $attachment_id, $attachment_data );
25 }
26 }
27
28 }
29
30 update_option( 'innofit_media_id', $ImageId );
31 ?>