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