| 1 |
<?php |
| 2 |
/** |
| 3 |
* Outputs the Import and Export screen. |
| 4 |
* |
| 5 |
* @package WPZinc\Shared |
| 6 |
* @author WP Zinc |
| 7 |
*/ |
| 8 |
|
| 9 |
// Exit if accessed directly. |
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
?> |
| 15 |
<header> |
| 16 |
<h1> |
| 17 |
<?php echo esc_html( $this->plugin->displayName ); ?> |
| 18 |
|
| 19 |
<span> |
| 20 |
<?php esc_html_e( 'Import & Export', 'wp-to-buffer' ); ?> |
| 21 |
</span> |
| 22 |
</h1> |
| 23 |
</header> |
| 24 |
|
| 25 |
<hr class="wp-header-end" /> |
| 26 |
|
| 27 |
<div class="wrap"> |
| 28 |
<div class="wrap-inner"> |
| 29 |
<?php |
| 30 |
// Notices. |
| 31 |
if ( isset( $this->message ) && ! empty( $this->message ) ) { |
| 32 |
?> |
| 33 |
<div class="updated notice"><p><?php echo esc_html( $this->message ); ?></p></div> |
| 34 |
<?php |
| 35 |
} |
| 36 |
if ( isset( $this->error_message ) && ! empty( $this->error_message ) ) { |
| 37 |
?> |
| 38 |
<div class="error notice"><p><?php echo esc_html( $this->error_message ); ?></p></div> |
| 39 |
<?php |
| 40 |
} |
| 41 |
?> |
| 42 |
|
| 43 |
<!-- Tabs --> |
| 44 |
<h2 class="nav-tab-wrapper wpzinc-horizontal-tabbed-ui"> |
| 45 |
<a href="<?php echo esc_url( $this->plugin->documentation_url ); ?>" class="nav-tab last documentation" rel="noopener" target="_blank"> |
| 46 |
<?php esc_html_e( 'Documentation', 'wp-to-buffer' ); ?> |
| 47 |
<span class="dashicons dashicons-admin-page"></span> |
| 48 |
</a> |
| 49 |
</h2> |
| 50 |
|
| 51 |
<form name="post" method="post" action="<?php echo ( isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' ); ?>" id="<?php echo esc_attr( $this->plugin->name ); ?>" enctype="multipart/form-data"> |
| 52 |
<div id="poststuff"> |
| 53 |
<div id="post-body" class="metabox-holder columns-1"> |
| 54 |
<!-- Content --> |
| 55 |
<div id="post-body-content"> |
| 56 |
<div id="normal-sortables" class="meta-box-sortables ui-sortable publishing-defaults"> |
| 57 |
<div class="postbox wpzinc-vertical-tabbed-ui"> |
| 58 |
<!-- Second level tabs --> |
| 59 |
<ul class="wpzinc-nav-tabs wpzinc-js-tabs" data-panels-container="#import-export-container" data-panel=".panel" data-active="wpzinc-nav-tab-vertical-active"> |
| 60 |
<li class="wpzinc-nav-tab download"> |
| 61 |
<a href="#import" class="wpzinc-nav-tab-vertical-active"> |
| 62 |
<?php esc_html_e( 'Import', 'wp-to-buffer' ); ?> |
| 63 |
</a> |
| 64 |
</li> |
| 65 |
<?php |
| 66 |
if ( is_array( $import_sources ) && count( $import_sources ) > 0 ) { |
| 67 |
foreach ( $import_sources as $import_source ) { |
| 68 |
?> |
| 69 |
<li class="wpzinc-nav-tab <?php echo esc_attr( $import_source['name'] ); ?>"> |
| 70 |
<a href="#<?php echo esc_attr( $import_source['name'] ); ?>"> |
| 71 |
<?php echo esc_html( $import_source['label'] ); ?> |
| 72 |
</a> |
| 73 |
</li> |
| 74 |
<?php |
| 75 |
} |
| 76 |
} |
| 77 |
?> |
| 78 |
<li class="wpzinc-nav-tab upload"> |
| 79 |
<a href="#export"> |
| 80 |
<?php esc_html_e( 'Export', 'wp-to-buffer' ); ?> |
| 81 |
</a> |
| 82 |
</li> |
| 83 |
</ul> |
| 84 |
|
| 85 |
<!-- Content --> |
| 86 |
<div id="import-export-container" class="wpzinc-nav-tabs-content"> |
| 87 |
<!-- Import --> |
| 88 |
<div id="import" class="panel"> |
| 89 |
<div class="postbox"> |
| 90 |
<header> |
| 91 |
<h3><?php esc_html_e( 'Import', 'wp-to-buffer' ); ?></h3> |
| 92 |
<p class="description"> |
| 93 |
<?php esc_html_e( 'Upload a file generated by this Plugin\'s export functionality (JSON or zipped JSON). This will overwrite any existing settings stored on this installation.', 'wp-to-buffer' ); ?> |
| 94 |
</p> |
| 95 |
</header> |
| 96 |
|
| 97 |
<div class="wpzinc-option"> |
| 98 |
<div class="left"> |
| 99 |
<label for="file"><?php esc_html_e( 'JSON File', 'wp-to-buffer' ); ?></label> |
| 100 |
</div> |
| 101 |
<div class="right"> |
| 102 |
<input type="file" id="file" name="import" /> |
| 103 |
</div> |
| 104 |
</div> |
| 105 |
|
| 106 |
<div class="wpzinc-option"> |
| 107 |
<input name="import" type="submit" class="button button-primary" value="<?php esc_attr_e( 'Import', 'wp-to-buffer' ); ?>" /> |
| 108 |
</div> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
|
| 112 |
<?php |
| 113 |
if ( is_array( $import_sources ) && count( $import_sources ) > 0 ) { |
| 114 |
foreach ( $import_sources as $import_source ) { |
| 115 |
include_once $import_source['view']; |
| 116 |
} |
| 117 |
} |
| 118 |
?> |
| 119 |
|
| 120 |
<!-- Export --> |
| 121 |
<div id="export" class="panel"> |
| 122 |
<div class="postbox"> |
| 123 |
<header> |
| 124 |
<h3><?php esc_html_e( 'Export', 'wp-to-buffer' ); ?></h3> |
| 125 |
<p class="description"> |
| 126 |
<?php esc_html_e( 'To export this Plugin\'s settings, choose which item(s) to export, and click the Export button below.', 'wp-to-buffer' ); ?> |
| 127 |
<br /> |
| 128 |
<?php esc_html_e( 'You can then import the generated file into another Plugin installation.', 'wp-to-buffer' ); ?> |
| 129 |
<br /> |
| 130 |
<?php esc_html_e( 'Including this file in a support request? We recommend setting the Format option to "Export as JSON, Zipped".', 'wp-to-buffer' ); ?> |
| 131 |
</p> |
| 132 |
</header> |
| 133 |
|
| 134 |
<?php |
| 135 |
/** |
| 136 |
* Add any form options to the Export screen |
| 137 |
* |
| 138 |
* @since 1.0.0 |
| 139 |
*/ |
| 140 |
do_action( str_replace( '-', '_', $this->plugin->name ) . '_export_view' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName |
| 141 |
?> |
| 142 |
|
| 143 |
<div class="wpzinc-option"> |
| 144 |
<div class="left"> |
| 145 |
<label for="format"><?php esc_html_e( 'Format', 'wp-to-buffer' ); ?></label> |
| 146 |
</div> |
| 147 |
<div class="right"> |
| 148 |
<select name="format" id="format" size="1"> |
| 149 |
<option value="json"><?php esc_html_e( 'JSON', 'wp-to-buffer' ); ?></option> |
| 150 |
<option value="zip"><?php esc_html_e( 'JSON, Zipped', 'wp-to-buffer' ); ?></option> |
| 151 |
</select> |
| 152 |
</div> |
| 153 |
</div> |
| 154 |
|
| 155 |
<div class="wpzinc-option"> |
| 156 |
<input name="export" type="submit" class="button button-primary" value="<?php esc_attr_e( 'Export', 'wp-to-buffer' ); ?>" /> |
| 157 |
</div> |
| 158 |
</div> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
|
| 163 |
<?php |
| 164 |
wp_nonce_field( $this->plugin->name, $this->plugin->name . '_nonce' ); |
| 165 |
?> |
| 166 |
</div> |
| 167 |
<!-- /normal-sortables --> |
| 168 |
</div> |
| 169 |
<!-- /post-body-content --> |
| 170 |
</div> |
| 171 |
</div> |
| 172 |
<!-- /poststuff --> |
| 173 |
</form> |
| 174 |
</div> |
| 175 |
</div> |
| 176 |
|