PluginProbe
Assistant – Every Day Productivity Apps / 1.2.0
Assistant – Every Day Productivity Apps v1.2.0
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
← All changes | backend/src/Services/MediaLibraryService.php +10 -7 0.7.11.2.0 View file →
@@ -66,9 +66,12 @@
66 66 case 'image/jpg':
67 67 case 'image/jpeg':
68 68 case 'image/png':
69 69 case 'image/gif':
70 - $response = $this->import_image( $media->url, $media->file_name, $post_id );
70 + case 'application/pdf':
71 + case 'application/rtf':
72 + case 'text/rtf':
73 + $response = $this->import_file( $media->url, $media->file_name, $post_id );
71 74 break;
72 75 case 'image/svg':
73 76 case 'image/svg+xml':
74 77 $response = $this->import_svg( $media->url, $media->file_name, $post_id );
@@ -82,11 +85,11 @@
82 85 return $response;
83 86 }
84 87
85 88 /**
86 - * Import an image into the media library.
89 + * Import a file into the media library.
87 90 */
88 - public function import_image( $url, $name, $post_id = 0 ) {
91 + public function import_file( $url, $name, $post_id = 0 ) {
89 92 require_once( ABSPATH . 'wp-admin/includes/image.php' );
90 93 require_once( ABSPATH . 'wp-admin/includes/file.php' );
91 94 require_once( ABSPATH . 'wp-admin/includes/media.php' );
92 95
@@ -110,9 +113,9 @@
110 113 $response_code = wp_remote_retrieve_response_code( $response );
111 114
112 115 if ( 200 !== intval( $response_code ) ) {
113 116 @unlink( $tmp_path );
114 - return [ 'error' => __( 'Error downloading image file.' ) ];
117 + return [ 'error' => __( 'Error downloading file.' ) ];
115 118 }
116 119
117 120 $id = media_handle_sideload(
118 121 [
@@ -123,9 +126,9 @@
123 126 );
124 127
125 128 if ( is_wp_error( $id ) ) {
126 129 @unlink( $tmp_path );
127 - return [ 'error' => __( 'Error importing image file.' ) ];
130 + return [ 'error' => __( 'Error importing file.' ) ];
128 131 }
129 132
130 133 return [
131 134 'id' => $id,
@@ -132,15 +135,15 @@
132 135 'url' => wp_get_attachment_url( $id ),
133 136 ];
134 137 }
135 138
139 +
136 140 /**
137 141 * Import an svg file into the media library.
138 142 */
139 143 public function import_svg( $url, $name, $post_id = 0 ) {
140 144 $this->add_svg_import_filters();
141 -
142 - return $this->import_image( $url, $name, $post_id );
145 + return $this->import_file( $url, $name, $post_id );
143 146 }
144 147
145 148 /**
146 149 * WP core media filters for allowing svg upload.