@@ -772,16 +772,22 @@ public function render_screen_tools( string $settings, $screen ): string {
772772
773773 if ( $ this ->config ['export_import ' ] ) {
774774 $ tools .= $ this ->tool (
775- __ ( 'Settings file ' , 'arraypress ' ),
776- __ ( 'Download this page \'s settings, or read a file back. Encrypted values are not exported — they cannot be read on another site. ' , 'arraypress ' ),
777- $ this ->action_form ( 'export ' , __ ( 'Export ' , 'arraypress ' ), 'button ' ) . $ this ->import_form ()
775+ __ ( 'Export ' , 'arraypress ' ),
776+ __ ( 'Download this page \'s settings as a JSON file. Encrypted values are left out — they cannot be read on another site. ' , 'arraypress ' ),
777+ $ this ->action_form ( 'export ' , __ ( 'Export settings ' , 'arraypress ' ), 'button ' )
778+ );
779+
780+ $ tools .= $ this ->tool (
781+ __ ( 'Import ' , 'arraypress ' ),
782+ __ ( 'Read a settings file back. Every value is sanitized by its own field, and anything that is not a field on this page is ignored. ' , 'arraypress ' ),
783+ $ this ->import_form ()
778784 );
779785 }
780786
781787 if ( $ this ->config ['reset_button ' ] ) {
782788 $ tools .= $ this ->tool (
783789 __ ( 'Reset ' , 'arraypress ' ),
784- __ ( 'Restore every setting on this tab to its default. ' , 'arraypress ' ),
790+ __ ( 'Restore every setting on the tab you are viewing to its default. ' , 'arraypress ' ),
785791 $ this ->action_form (
786792 'reset ' ,
787793 __ ( 'Reset this tab ' , 'arraypress ' ),
@@ -857,20 +863,35 @@ private function action_form( string $action, string $label, string $classes, st
857863 * @return string
858864 */
859865 private function import_form (): string {
860- // Numbered throughout: the id appears twice, and mixing numbered
861- // with unnumbered placeholders advances two separate counters.
866+ // core's own import form, from wp_import_upload_form(): a
867+ // .wp-upload-form, a *visible* label saying what to choose, the size
868+ // limit beside it, and a plain file input. A file input is what core
869+ // uses — hiding one behind a styled button is the part that would not
870+ // be core-like.
871+ //
872+ // Numbered throughout: the id appears twice, and mixing numbered with
873+ // unnumbered placeholders advances two separate counters.
874+ $ bytes = wp_max_upload_size ();
875+
862876 return sprintf (
863- '<form method="post" enctype="multipart/form-data" action="%1$s">%2$s ' .
877+ '<form method="post" enctype="multipart/form-data" action="%1$s" class="wp-upload-form" >%2$s ' .
864878 '<input type="hidden" name="action" value="%3$s" /> ' .
865- '<label class="screen-reader-text" for="%4$s-import">%5$s</label> ' .
866- '<input type="file" id="%4$s-import" name="import" accept="application/json,.json" required /> ' .
867- '<button type="submit" class="button">%6$s</button></form> ' ,
879+ '<input type="hidden" name="max_file_size" value="%7$d" /> ' .
880+ '<p><label for="%4$s-import">%5$s</label> <span class="description">(%8$s)</span></p> ' .
881+ '<p><input type="file" id="%4$s-import" name="import" accept="application/json,.json" required /></p> ' .
882+ '<p class="submit"><button type="submit" class="button">%6$s</button></p></form> ' ,
868883 esc_url ( admin_url ( 'admin-post.php ' ) ),
869884 wp_nonce_field ( $ this ->action_slug ( 'import ' ), '_wpnonce ' , false , false ),
870885 esc_attr ( $ this ->action_slug ( 'import ' ) ),
871886 esc_attr ( $ this ->id ),
872- esc_html__ ( 'Settings file to import ' , 'arraypress ' ),
873- esc_html__ ( 'Import ' , 'arraypress ' )
887+ esc_html__ ( 'Choose a settings file from your computer: ' , 'arraypress ' ),
888+ esc_html__ ( 'Import ' , 'arraypress ' ),
889+ (int ) $ bytes ,
890+ sprintf (
891+ /* translators: %s: maximum allowed upload size */
892+ esc_html__ ( 'Maximum size: %s ' , 'arraypress ' ),
893+ esc_html ( size_format ( $ bytes ) )
894+ )
874895 );
875896 }
876897
0 commit comments