MS_View_Settings_Page_Import

Render the Settings > Import Tool pages.

Defined (1)

The class is defined in the following location(s).

/app/view/settings/page/class-ms-view-settings-page-import.php  
  1. class MS_View_Settings_Page_Import extends MS_View_Settings_Edit { 
  2.  
  3. public function to_html() { 
  4. $export_action = MS_Controller_Import::ACTION_EXPORT; 
  5. $import_action = MS_Controller_Import::ACTION_PREVIEW; 
  6. $messages = $this->data['message']; 
  7.  
  8. $preview = false; 
  9. if ( isset( $messages['preview'] ) ) { 
  10. $preview = $messages['preview']; 
  11.  
  12. $export_fields = array( 
  13. 'export' => array( 
  14. 'id' => 'btn_export',  
  15. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  16. 'value' => __( 'Generate Export', 'membership2' ),  
  17. 'desc' => __( 
  18. 'Generate an export file with the current membership settings. ' . 
  19. '<em>Note that this is not a full backup of the plugin settings.</em>',  
  20. 'membership2' 
  21. ),  
  22. ),  
  23. 'action' => array( 
  24. 'id' => 'action',  
  25. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  26. 'value' => $export_action,  
  27. ),  
  28. 'nonce' => array( 
  29. 'id' => '_wpnonce',  
  30. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  31. 'value' => wp_create_nonce( $export_action ),  
  32. ),  
  33. ); 
  34.  
  35. $file_field = array( 
  36. 'id' => 'upload',  
  37. 'type' => MS_Helper_Html::INPUT_TYPE_FILE,  
  38. 'title' => __( 'From export file', 'membership2' ),  
  39. ); 
  40. $import_options = array( 
  41. 'file' => array( 
  42. 'text' => MS_Helper_Html::html_element( $file_field, true ),  
  43. 'disabled' => ! MS_Model_Import_File::present(),  
  44. ),  
  45. 'membership' => array( 
  46. 'text' => __( 'Membership (WPMU DEV)', 'membership2' ),  
  47. 'disabled' => ! MS_Model_Import_Membership::present(),  
  48. ),  
  49. ); 
  50.  
  51. $sel_source = 'file'; 
  52. if ( isset( $_POST['import_source'] ) 
  53. && isset( $import_options[ $_POST['import_source'] ] ) 
  54. ) { 
  55. $sel_source = $_POST['import_source']; 
  56.  
  57. $import_fields = array( 
  58. 'source' => array( 
  59. 'id' => 'import_source',  
  60. 'type' => MS_Helper_Html::INPUT_TYPE_RADIO,  
  61. 'title' => __( 'Choose an import source', 'membership2' ),  
  62. 'field_options' => $import_options,  
  63. 'value' => $sel_source,  
  64. ),  
  65. 'import' => array( 
  66. 'id' => 'btn_import',  
  67. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  68. 'value' => __( 'Preview Import', 'membership2' ),  
  69. 'desc' => __( 
  70. 'Import data into this installation.',  
  71. 'membership2' 
  72. ),  
  73. ),  
  74. 'action' => array( 
  75. 'id' => 'action',  
  76. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  77. 'value' => $import_action,  
  78. ),  
  79. 'nonce' => array( 
  80. 'id' => '_wpnonce',  
  81. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  82. 'value' => wp_create_nonce( $import_action ),  
  83. ),  
  84. ); 
  85.  
  86. ob_start(); 
  87.  
  88. MS_Helper_Html::settings_tab_header( 
  89. array( 'title' => __( 'Import Tool', 'membership2' ) ) 
  90. ); 
  91. ?> 
  92.  
  93. <div> 
  94. <?php if ( $preview ) : ?> 
  95. <form action="" method="post"> 
  96. <?php echo '' . $preview; ?> 
  97. </form> 
  98. <?php else : ?> 
  99. <form action="" method="post" enctype="multipart/form-data"> 
  100. <?php MS_Helper_Html::settings_box( 
  101. $import_fields,  
  102. __( 'Import data', 'membership2' ) 
  103. ); ?> 
  104. </form> 
  105. <form action="" method="post"> 
  106. <?php MS_Helper_Html::settings_box( 
  107. $export_fields,  
  108. __( 'Export data', 'membership2' ) 
  109. ); ?> 
  110. </form> 
  111. <?php endif; ?> 
  112. </div> 
  113. <?php 
  114. return ob_get_clean(); 
  115.