@@ -386,29 +386,51 @@ public function render_page(): void {
386386 ?>
387387 </form>
388388
389- <?php $ this ->render_export_import_ui (); ?>
389+ <?php if ( $ this ->config ['export_import ' ] ) : ?>
390+ <div class="setting-fields-export-import-result" style="display: none;">
391+ <span class="dashicons setting-fields-export-import-icon"></span>
392+ <span class="setting-fields-export-import-message"></span>
393+ </div>
394+ <?php endif ; ?>
390395 </div>
391396 <?php
392397 }
393398
394399 /**
395- * Render footer action buttons (submit, reset, export/import).
400+ * Render footer action buttons (submit only).
401+ *
402+ * Reset and export/import actions are rendered in the header.
396403 *
397404 * @return void
398405 */
399406 protected function render_footer_actions (): void {
400- if ( ! $ this ->config ['submit_button ' ] && ! $ this -> config [ ' reset_button ' ] ) {
407+ if ( ! $ this ->config ['submit_button ' ] ) {
401408 return ;
402409 }
403410
404- echo '<div class="setting-fields-footer-actions"> ' ;
411+ submit_button ();
412+ }
405413
406- if ( $ this ->config ['submit_button ' ] ) {
407- submit_button ( null , 'primary ' , 'submit ' , false );
414+ /**
415+ * Render header action buttons (reset, export, import).
416+ *
417+ * Displayed in the header branding row, right-aligned.
418+ *
419+ * @param string $current_tab Current active tab.
420+ *
421+ * @return void
422+ */
423+ protected function render_header_actions ( string $ current_tab ): void {
424+ $ has_reset = $ this ->config ['reset_button ' ];
425+ $ has_export = $ this ->config ['export_import ' ];
426+
427+ if ( ! $ has_reset && ! $ has_export ) {
428+ return ;
408429 }
409430
410- if ( $ this ->config ['reset_button ' ] ) {
411- $ current_tab = $ this ->get_current_tab ();
431+ echo '<div class="setting-fields-header__actions"> ' ;
432+
433+ if ( $ has_reset ) {
412434 $ reset_label = ! empty ( $ this ->tabs )
413435 ? sprintf ( __ ( 'Reset %s ' , 'setting-fields ' ), $ this ->tabs [ $ current_tab ]['label ' ] ?? __ ( 'Tab ' , 'setting-fields ' ) )
414436 : __ ( 'Reset to Defaults ' , 'setting-fields ' );
@@ -422,51 +444,28 @@ class="button setting-fields-reset-btn"
422444 <?php
423445 }
424446
425- echo '</div> ' ;
426- }
427-
428- /**
429- * Render the export/import UI below the form.
430- *
431- * Only rendered when 'export_import' is enabled.
432- *
433- * @return void
434- */
435- protected function render_export_import_ui (): void {
436- if ( ! $ this ->config ['export_import ' ] ) {
437- return ;
438- }
447+ if ( $ has_export ) {
448+ ?>
449+ <button type="button" class="button setting-fields-export-btn">
450+ <span class="dashicons dashicons-download"></span>
451+ <?php esc_html_e ( 'Export Settings ' , 'setting-fields ' ); ?>
452+ </button>
439453
440- ? >
441- <div class="setting-fields-export-import">
442- <h3> <?php esc_html_e ( ' Export / Import ' , ' setting-fields ' ); ?> </h3>
443- <p class="description"> <?php esc_html_e ( ' Export your settings as a JSON file or import from a previously exported file. ' , ' setting-fields ' ); ?> </p>
444-
445- <div class="setting-fields-export-import-actions" >
446- <button type="button" class="button setting-fields-export -btn">
447- <span class="dashicons dashicons-download "></span>
448- <?php esc_html_e ( 'Export Settings ' , 'setting-fields ' ); ?>
454+ <div class="setting-fields-import-wrap" >
455+ <input type="file"
456+ accept=".json"
457+ class=" setting-fields-import-file"
458+ id=" <?php echo esc_attr ( $ this -> id ); ?> _import_file"
459+ style="display:none;"/ >
460+ <button type="button" class="button setting-fields-import -btn">
461+ <span class="dashicons dashicons-upload "></span>
462+ <?php esc_html_e ( 'Import Settings ' , 'setting-fields ' ); ?>
449463 </button>
450-
451- <div class="setting-fields-import-wrap">
452- <input type="file"
453- accept=".json"
454- class="setting-fields-import-file"
455- id="<?php echo esc_attr ( $ this ->id ); ?> _import_file"
456- style="display:none;" />
457- <button type="button" class="button setting-fields-import-btn">
458- <span class="dashicons dashicons-upload"></span>
459- <?php esc_html_e ( 'Import Settings ' , 'setting-fields ' ); ?>
460- </button>
461- </div>
462464 </div>
465+ <?php
466+ }
463467
464- <div class="setting-fields-export-import-result" style="display: none;">
465- <span class="dashicons setting-fields-export-import-icon"></span>
466- <span class="setting-fields-export-import-message"></span>
467- </div>
468- </div>
469- <?php
468+ echo '</div> ' ;
470469 }
471470
472471 /**
@@ -510,6 +509,8 @@ protected function render_header( string $current_tab ): void {
510509 <?php if ( ! empty ( $ header_badge ) ) : ?>
511510 <?php self ::render_header_badge ( $ header_badge ); ?>
512511 <?php endif ; ?>
512+
513+ <?php $ this ->render_header_actions ( $ current_tab ); ?>
513514 </div>
514515 </div>
515516
@@ -687,6 +688,7 @@ protected function render_field_row( string $field_key, array $field ): void {
687688 $ type = $ field ['type ' ] ?? 'text ' ;
688689 if ( $ type === 'hidden ' ) {
689690 $ this ->render_field ( $ field_key , $ field , $ field_name , $ field_id , $ value );
691+
690692 return ;
691693 }
692694
@@ -871,7 +873,15 @@ public function export_settings(): array {
871873 }
872874
873875 // Skip layout fields that have no stored data
874- if ( in_array ( $ field ['type ' ] ?? '' , [ 'message ' , 'html ' , 'separator ' , 'heading ' , 'hidden ' , 'action_button ' , 'clipboard ' ], true ) ) {
876+ if ( in_array ( $ field ['type ' ] ?? '' , [
877+ 'message ' ,
878+ 'html ' ,
879+ 'separator ' ,
880+ 'heading ' ,
881+ 'hidden ' ,
882+ 'action_button ' ,
883+ 'clipboard '
884+ ], true ) ) {
875885 continue ;
876886 }
877887
0 commit comments