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