| 1 |
<?php |
| 2 |
/** |
| 3 |
* HTML for the Import Snippets page. |
| 4 |
* |
| 5 |
* @package Code_Snippets |
| 6 |
* @subpackage Views |
| 7 |
* |
| 8 |
* @var Import_Menu $this |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace Code_Snippets; |
| 12 |
|
| 13 |
/* Bail if accessed directly */ |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
$max_size_bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
| 19 |
|
| 20 |
?> |
| 21 |
<div class="wrap"> |
| 22 |
<h1> |
| 23 |
<?php |
| 24 |
|
| 25 |
esc_html_e( 'Import Snippets', 'code-snippets' ); |
| 26 |
|
| 27 |
if ( code_snippets()->is_compact_menu() ) { |
| 28 |
$this->page_title_actions( [ 'manage', 'add', 'settings' ] ); |
| 29 |
} |
| 30 |
|
| 31 |
?> |
| 32 |
</h1> |
| 33 |
|
| 34 |
<?php $this->print_messages(); ?> |
| 35 |
|
| 36 |
<div class="narrow"> |
| 37 |
|
| 38 |
<p><?php esc_html_e( 'Upload one or more Code Snippets export files and the snippets will be imported.', 'code-snippets' ); ?></p> |
| 39 |
|
| 40 |
<p> |
| 41 |
<?php |
| 42 |
/* translators: %s: link to snippets admin menu */ |
| 43 |
$text = __( 'Afterwards, you will need to visit the <a href="%s">All Snippets</a> page to activate the imported snippets.', 'code-snippets' ); |
| 44 |
|
| 45 |
printf( wp_kses( $text, [ 'a' => [ 'href' ] ] ), esc_url( code_snippets()->get_menu_url( 'manage' ) ) ); |
| 46 |
|
| 47 |
?> |
| 48 |
</p> |
| 49 |
|
| 50 |
|
| 51 |
<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" |
| 52 |
name="code_snippets_import"> |
| 53 |
<?php wp_nonce_field( 'import_code_snippets_file' ); ?> |
| 54 |
|
| 55 |
<h2><?php esc_html_e( 'Duplicate Snippets', 'code-snippets' ); ?></h2> |
| 56 |
|
| 57 |
<p class="description"> |
| 58 |
<?php esc_html_e( 'What should happen if an existing snippet is found with an identical name to an imported snippet?', 'code-snippets' ); ?> |
| 59 |
</p> |
| 60 |
|
| 61 |
<fieldset> |
| 62 |
<p> |
| 63 |
<label> |
| 64 |
<input type="radio" name="duplicate_action" value="ignore" checked="checked"> |
| 65 |
<?php esc_html_e( 'Ignore any duplicate snippets: import all snippets from the file regardless and leave all existing snippets unchanged.', 'code-snippets' ); ?> |
| 66 |
</label> |
| 67 |
</p> |
| 68 |
|
| 69 |
<p> |
| 70 |
<label> |
| 71 |
<input type="radio" name="duplicate_action" value="replace"> |
| 72 |
<?php esc_html_e( 'Replace any existing snippets with a newly imported snippet of the same name.', 'code-snippets' ); ?> |
| 73 |
</label> |
| 74 |
</p> |
| 75 |
|
| 76 |
<p> |
| 77 |
<label> |
| 78 |
<input type="radio" name="duplicate_action" value="skip"> |
| 79 |
<?php esc_html_e( 'Do not import any duplicate snippets; leave all existing snippets unchanged.', 'code-snippets' ); ?> |
| 80 |
</label> |
| 81 |
</p> |
| 82 |
</fieldset> |
| 83 |
|
| 84 |
<h2><?php esc_html_e( 'Upload Files', 'code-snippets' ); ?></h2> |
| 85 |
|
| 86 |
<p class="description"> |
| 87 |
<?php esc_html_e( 'Choose one or more Code Snippets (.xml or .json) files to upload, then click "Upload files and import".', 'code-snippets' ); ?> |
| 88 |
</p> |
| 89 |
|
| 90 |
<fieldset> |
| 91 |
<p> |
| 92 |
<label for="upload"><?php esc_html_e( 'Choose files from your computer:', 'code-snippets' ); ?></label> |
| 93 |
<?php |
| 94 |
/* translators: %s: size in bytes */ |
| 95 |
printf( esc_html__( '(Maximum size: %s)', 'code-snippets' ), esc_html( size_format( $max_size_bytes ) ) ); ?> |
| 96 |
<input type="file" id="upload" name="code_snippets_import_files[]" size="25" |
| 97 |
accept="application/json,.json,text/xml" multiple="multiple"> |
| 98 |
<input type="hidden" name="action" value="save"> |
| 99 |
<input type="hidden" name="max_file_size" value="<?php echo esc_attr( $max_size_bytes ); ?>"> |
| 100 |
</p> |
| 101 |
</fieldset> |
| 102 |
|
| 103 |
<?php |
| 104 |
|
| 105 |
do_action( 'code_snippets/admin/import_form' ); |
| 106 |
submit_button( __( 'Upload files and import', 'code-snippets' ) ); |
| 107 |
|
| 108 |
?> |
| 109 |
</form> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
|