Plugin Directory

Changeset 2406637


Ignore:
Timestamp:
10/26/2020 08:53:45 AM (5 years ago)
Author:
munger41
Message:

1.6.5 - Add messages on upload errors

Location:
indesignhtml2post/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • indesignhtml2post/trunk/InDesignHTML2Post.php

    r2259123 r2406637  
    44 * Plugin URI: https://fr.wordpress.org/plugins/indesignhtml2post/
    55 * Description: Convert HTML InDesign exports to posts (imports all text and images - and attach images automatically to newly created posts).
    6  * Version: 1.6.4
     6 * Version: 1.6.5
    77 * Author: termel
    88 * Author URI: https://www.indesign2wordpress.com/
     
    11531153           
    11541154            if (isset($attachedImagesArray[$imgFileToInsert])) {
    1155                 $attachId = $attachedImagesArray[$imgFileToInsert];
     1155                $attachId = is_numeric($attachedImagesArray[$imgFileToInsert]);
    11561156                $foundAttachmentId = is_numeric($attachId) ? $attachId : -1;
    11571157            } else if (isset($resizedImagesArrayNames[$imgFileToInsert]) && isset($attachedImagesArray[$resizedImagesArrayNames[$imgFileToInsert]])) {
     
    13181318            return $upload_dir;
    13191319        }
     1320       
     1321        private function codeToMessage($code)
     1322        {
     1323            switch ($code) {
     1324                case UPLOAD_ERR_INI_SIZE:
     1325                    $message = "The uploaded file exceeds the upload_max_filesize directive in php.ini";
     1326                    break;
     1327                case UPLOAD_ERR_FORM_SIZE:
     1328                    $message = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form";
     1329                    break;
     1330                case UPLOAD_ERR_PARTIAL:
     1331                    $message = "The uploaded file was only partially uploaded";
     1332                    break;
     1333                case UPLOAD_ERR_NO_FILE:
     1334                    $message = "No file was uploaded";
     1335                    break;
     1336                case UPLOAD_ERR_NO_TMP_DIR:
     1337                    $message = "Missing a temporary folder";
     1338                    break;
     1339                case UPLOAD_ERR_CANT_WRITE:
     1340                    $message = "Failed to write file to disk";
     1341                    break;
     1342                case UPLOAD_ERR_EXTENSION:
     1343                    $message = "File upload stopped by extension";
     1344                    break;
     1345                   
     1346                default:
     1347                    $message = "Unknown upload error";
     1348                    break;
     1349            }
     1350            return $message;
     1351        }
    13201352
    13211353        function handle_indesign_html_export($post_max_size = 8000)
     
    13521384                        $unzipped = array();
    13531385                        if (! is_admin()) {
    1354                             require_once (ABSPATH . 'wp-admin/includes/file.php');
     1386                            $path_to_include = ABSPATH . 'wp-admin/includes/file.php';
     1387                            InDesignHTML2Post_log($path_to_include);
     1388                            require_once ($path_to_include);
     1389                        } else {
     1390                            InDesignHTML2Post_log("Is admin page");
    13551391                        }
    13561392                        WP_Filesystem();
    13571393                        $uploadDir = wp_upload_dir();
     1394                        InDesignHTML2Post_log($uploadDir);
    13581395                        $writeToPath = trailingslashit($uploadDir['path']);
     1396                        InDesignHTML2Post_log($writeToPath);
    13591397                        foreach ($_FILES as $fid => $array) {
    13601398                            $request_answer = "-> file to upload : " . $fid . ' / ' . $filename . " (" . $array['name'] . ") / " . $array['type'] . " / " . $array['tmp_name'];
     1399                           
    13611400                            if ($array['error'] !== UPLOAD_ERR_OK) {
    1362                                 $msg = $array['error'];
     1401                                $err_id = $array['error'];
     1402                                $msg = $this->codeToMessage($err_id);
     1403                                InDesignHTML2Post_log($msg);
    13631404                                $request_answer .= $this->displayHTMLStatusOfCmd($filename, $msg, $array['error']);
    13641405                                return $msg;
     1406                            } else {
     1407                                $msg = "File uploaded without error :)";
     1408                                InDesignHTML2Post_log($msg);
    13651409                            }
    13661410                           
  • indesignhtml2post/trunk/readme.txt

    r2259204 r2406637  
    4343== Changelog ==
    4444
     451.6.5 - Add messages on upload errors
     46
    45471.6.4 - bug fix on attachment ID lookup
    4648
Note: See TracChangeset for help on using the changeset viewer.