PluginProbe
TablePress – Tables in WordPress made easy / 3.0
TablePress – Tables in WordPress made easy v3.0
3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.4.4 All 44 releases
← All changes | classes/class-import.php +3 -43 3.3.13.0 View file →
@@ -130,15 +130,12 @@
130 130 if ( in_array( $ip, $blocked_ips, true ) ) {
131 131 return new WP_Error( 'table_import_url_host_blocked', '', array( 'url' => $this->import_config['url'], 'ip' => $ip ) );
132 132 }
133 133
134 - // Automatically adjust URLs of common services to point to a direct download URL.
135 - $this->import_config['url'] = $this->fix_common_url_mistakes( $this->import_config['url'] );
136 -
137 134 /**
138 135 * Load WP file functions to be sure that `download_url()` exists, in particular during Cron requests.
139 136 */
140 - require_once ABSPATH . 'wp-admin/includes/file.php';
137 + require_once ABSPATH . 'wp-admin/includes/file.php'; // @phpstan-ignore requireOnce.fileNotFound (This is a WordPress core file that always exists.)
141 138
142 139 // Download URL to local file.
143 140 $location = download_url( $this->import_config['url'] );
144 141 if ( is_wp_error( $location ) ) {
@@ -187,45 +184,8 @@
187 184 return $import_files;
188 185 }
189 186
190 187 /**
191 - * Fixes common mistakes in URLs from popular services to point to a direct download URL.
192 - *
193 - * Currently supports Google Sheets, Microsoft OneDrive, and Dropbox.
194 - * See https://tablepress.org/tutorials/ for more specific instructions on how to get the correct URL.
195 - *
196 - * @since 3.2.4
197 - *
198 - * @param string $url URL that shall be fixed.
199 - * @return string Fixed URL.
200 - */
201 - protected function fix_common_url_mistakes( string $url ): string {
202 - /**
203 - * Filters whether common URL mistakes shall be fixed automatically.
204 - *
205 - * @since 3.2.4
206 - *
207 - * @param bool $fix_common_url_mistakes Whether to fix common URL mistakes. Default true.
208 - */
209 - if ( ! apply_filters( 'tablepress_import_fix_common_url_mistakes', true ) ) {
210 - return $url;
211 - }
212 -
213 - if ( str_starts_with( $url, 'https://docs.google.com/spreadsheets/' ) && str_ends_with( $url, '/edit?usp=sharing' ) ) {
214 - // Google Sheets "Sharing URL" to direct download URL.
215 - $url = str_replace( '/edit?usp=sharing', '/export?format=csv', $url );
216 - } elseif ( str_starts_with( $url, 'https://1drv.ms/' ) && ! str_ends_with( $url, '&download=1' ) ) {
217 - // OneDrive shared link to direct download link.
218 - $url .= '&download=1';
219 - } elseif ( str_starts_with( $url, 'https://www.dropbox.com/' ) && str_ends_with( $url, '&dl=0' ) ) {
220 - // Dropbox shared link to direct download link.
221 - $url = str_replace( '&dl=0', '&dl=1', $url );
222 - }
223 -
224 - return $url;
225 - }
226 -
227 - /**
228 188 * Replaces ZIP archives in the import files with a list of their contents.
229 189 *
230 190 * ZIP files are removed from the list and their contents are added to the end of the list.
231 191 *
@@ -409,9 +369,9 @@
409 369 */
410 370 protected function extract_zip_file_pclzip( File $zip_file ) /* : array|WP_Error */ {
411 371 mbstring_binary_safe_encoding();
412 372
413 - require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
373 + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; // @phpstan-ignore requireOnce.fileNotFound (This is a WordPress core file that always exists.)
414 374
415 375 $archive = new PclZip( $zip_file->location );
416 376 $archive_files = $archive->extract( PCLZIP_OPT_EXTRACT_AS_STRING ); // @phpstan-ignore arguments.count (PclZip::extract() uses `func_get_args()` to handle optional arguments.)
417 377
@@ -674,9 +634,9 @@
674 634 if ( '' === $format ) {
675 635 $format = 'csv';
676 636 }
677 637
678 - if ( ! in_array( $format, $this->importer->import_formats, true ) ) { // @phpstan-ignore property.notFound (`$this->importer` is an instance of `TablePress_Import_Legacy` which has the property `import_formats`.)
638 + if ( ! isset( $this->importer->import_formats[ $format ] ) ) {
679 639 return new WP_Error( 'table_import_legacy_unknown_format', '', $file->name );
680 640 }
681 641
682 642 $table = $this->importer->import_table( $format, $data );