@@ -46,13 +46,17 @@ function mathilda_import_tool() {
4646 $ twitter_import_path = mathilda_get_import_directory ();
4747
4848 /*
49- Arrays
49+ Variables & Arrays
5050 */
5151
5252 $ list_import_files_draft =array ();
5353 $ number_of_files_draft =0 ;
5454 $ list_import_files =array ();
5555 $ number_of_files =0 ;
56+ $ max_file_size =0 ;
57+ $ filesize_max_threshold =get_option ('mathilda_import_filesize_max ' );
58+ $ filesize_max_string =$ filesize_max_threshold ;
59+ $ filesize_max_string =$ filesize_max_string /1024 ;
5660
5761 /*
5862 Read Files @ Import Directory
@@ -105,6 +109,22 @@ function mathilda_import_tool() {
105109
106110 array_multisort ($ list_import_files );
107111
112+ /*
113+ Get Max File Size
114+ */
115+
116+ for ($ i =0 ; $ i <$ number_of_files ; $ i ++)
117+ {
118+
119+ $ filename_with_path =$ twitter_import_path . '/ ' . $ list_import_files [$ i ][0 ];
120+ $ filesize_this =filesize ($ filename_with_path );
121+
122+ if ($ filesize_this >$ max_file_size ) {
123+ $ max_file_size =$ filesize_this ;
124+ }
125+
126+ }
127+
108128 /*
109129 Check Number of Files
110130 */
@@ -116,10 +136,24 @@ function mathilda_import_tool() {
116136 echo 'Please follow the instructions below.</p> ' ;
117137 echo '<p><strong>Required Steps</strong></p> ' ;
118138 echo '<p>1. Download your tweet archive from Twitter (Profile/Settings).<br/> ' ;
119- echo '2. Upload all files from /data/js/tweets to /wp-content/uploads/mathilda-import.<br/> ' ;
120- echo '3. Run this import script again.</p> ' ;
139+ echo '2. Split the file data/tweets.js into smaller files (< ' .$ filesize_max_string .' KB) with a local app.<br/> ' ;
140+ echo '3. Upload all files to the folder wp-content/uploads/mathilda-import.</br> ' ;
141+ echo '4. Run this import script again.</p> ' ;
142+ echo '<p> <br/><a class="button" href=" ' .admin_url ().'tools.php?page=mathilda-tools-menu">Close</a></p> ' ;
143+ return ;
144+
145+ }
146+
147+ if ($ max_file_size >$ filesize_max_threshold ) {
148+
149+ echo '<p><strong>Error</strong></p> ' ;
150+ echo '<p>One or more files in the import folder are larger as ' .$ filesize_max_string .' KB.<br/> ' ;
151+ echo 'Unfortunately the import process is limited to files not larger as 400 KB.<br/> ' ;
152+ echo 'You must split the affected files in smaller files with a local app.<br/> ' ;
153+ echo 'After that run this import script again.</p> ' ;
121154 echo '<p> <br/><a class="button" href=" ' .admin_url ().'tools.php?page=mathilda-tools-menu">Close</a></p> ' ;
122155 return ;
156+
123157 }
124158
125159 if ($ number_of_files >0 ) {
0 commit comments