PluginProbe
Snippet Shortcodes / 4.1.6
Snippet Shortcodes v4.1.6
5.2.1 5.2 5.1.8 5.1.6 5.1.7 5.1.5 trunk 1.0 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 2.0 2.0.1 All 74 releases
← All changes | includes/pages/page.import.php +9 -57 5.2 → 4.1.6 View file →
@@ -1,39 +1,8 @@
1 1 <?php
2 2
3 3 defined('ABSPATH') or die('Naw ya dinnie!');
4 4
5 -/**
6 - * Stream the CSV export before any admin page HTML is output. Hooked on admin_init
7 - * rather than handled in the page callback itself, since by the time WordPress calls
8 - * the page callback it has already sent the admin header/menu chrome, making it too
9 - * late to send Content-Disposition/Content-Type headers for a file download.
10 - */
11 -function sh_cd_admin_page_import_maybe_export() {
12 -
13 - if ( false === isset( $_GET[ 'page' ] ) || 'sh-cd-import' !== $_GET[ 'page' ] || 'export' !== ( $_GET[ 'mode' ] ?? '' ) ) {
14 - return;
15 - }
16 -
17 - sh_cd_permission_check();
18 -
19 - if ( false === sh_cd_is_premium() ) {
20 - return;
21 - }
22 -
23 - check_admin_referer( 'sh_cd_export_csv' );
24 -
25 - $filename = 'snippet-shortcodes-export-' . gmdate( 'Y-m-d' ) . '.csv';
26 -
27 - nocache_headers();
28 - header( 'Content-Type: text/csv; charset=utf-8' );
29 - header( 'Content-Disposition: attachment; filename=' . $filename );
30 -
31 - echo sh_cd_export_csv();
32 - exit;
33 -}
34 -add_action( 'admin_init', 'sh_cd_admin_page_import_maybe_export' );
35 -
36 5 function sh_cd_admin_page_import() {
37 6
38 7 sh_cd_permission_check();
39 8
@@ -41,9 +10,9 @@
41 10
42 11 $importing = false;
43 12 $output = '';
44 13
45 - if ( true === sh_cd_is_premium() &&
14 + if ( true === SH_CD_IS_PREMIUM &&
46 15 false === empty( $_POST[ 'attachment-id' ] ) ){
47 16
48 17 $importing = true;
49 18 $dry_run = ( false === empty( $_POST[ 'dry-run' ] ) );
@@ -56,26 +25,22 @@
56 25 <div id="post-body" class="metabox-holder">
57 26 <div id="post-body-content">
58 27 <div class="meta-box-sortables ui-sortable">
59 28 <?php
60 - if ( false === sh_cd_is_premium() ) {
29 + if ( false === SH_CD_IS_PREMIUM ) {
61 30 sh_cd_display_pro_upgrade_notice();
62 31 }
63 32 ?>
64 33 <div class="postbox">
65 - <h3 class="postbox-header">
66 - <span>
67 - <?php echo __( 'Import CSV', SH_CD_SLUG ); ?>
68 - </span>
69 - </h3>
70 - <div class="inside">
34 + <h2 class="hndle"><?php echo __( 'Import CSV', SH_CD_SLUG ); ?></h2>
35 + <div class="inside">
71 36 <?php if ( false === $importing ): ?>
72 37 <div class="sh-cd-form-row">
73 38 <p>
74 - <?php echo __( 'Please select a CSV file to import one or more shortcodes into your collection.', SH_CD_SLUG ); ?>
75 - <a href="https://yeken.gitbook.io/snippet-shortcodes/features/csv-import" rel="noopener noreferrer" target="_blank"><?php echo __( 'Read more about CSV imports and the required format', SH_CD_SLUG ); ?>.</a>
39 + <?php echo __( 'Please select a CSV file to import one or shortcodes into your collection.', SH_CD_SLUG ); ?>
40 + <a href="https://snippet-shortcodes.yeken.uk/csv-import.html" rel="noopener noreferrer" target="_blank"><?php echo __( 'Read more about CSV imports and the required format', SH_CD_SLUG ); ?>.</a>
76 41 </p>
77 - <input id="select_csv" type="button" class="button sh-cd-button" value="<?php echo __( 'Select CSV file', SH_CD_SLUG ); ?>" />
42 + <input id="select_csv" type="button" class="button" value="<?php echo __( 'Select CSV file', SH_CD_SLUG ); ?>" />
78 43 <br />
79 44 </div>
80 45 <div class="sh-cd-hide sh-cd-import-selected" id="selected-form" >
81 46 <form action="<?php echo admin_url( 'admin.php?page=sh-cd-import&mode=import'); ?>" method="post">
@@ -88,9 +53,9 @@
88 53 <input type='checkbox' name='dry-run' id='dry-run' value='yes' />
89 54 <label for="dry-run"><?php echo __( 'Dry run mode. This will do basic tests on the file without performing an import.', SH_CD_SLUG ); ?></label>
90 55 </div>
91 56 <div class="sh-cd-form-row">
92 - <input type="submit" class="button button-primary sh-cd-button" value="<?php echo __( 'Import CSV', SH_CD_SLUG ); ?>" <?php if ( false === sh_cd_is_premium() ) { echo 'disabled="disabled"'; } ?> />
57 + <input type="submit" class="button button-primary" value="<?php echo __( 'Import CSV', SH_CD_SLUG ); ?>" <?php if ( false === SH_CD_IS_PREMIUM ) { echo 'disabled="disabled"'; } ?> />
93 58 </div>
94 59 </form>
95 60 </div>
96 61 <?php else: ?>
@@ -98,21 +63,8 @@
98 63 <textarea class="widefat" rows="20" cols="100"><?php echo esc_html( $output ); ?></textarea>
99 64 <?php endif; ?>
100 65 </div>
101 66 </div>
102 - <div class="postbox">
103 - <h3 class="postbox-header">
104 - <span>
105 - <?php echo __( 'Export to CSV', SH_CD_SLUG ); ?>
106 - </span>
107 - </h3>
108 - <div class="inside">
109 - <div class="sh-cd-form-row">
110 - <p><?php echo __( 'Download all of your shortcodes as a CSV file, in the same format used for import.', SH_CD_SLUG ); ?></p>
111 - <a class="button button-primary sh-cd-button" <?php if ( false === sh_cd_is_premium() ) { echo 'disabled="disabled"'; } ?> href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sh-cd-import&mode=export' ), 'sh_cd_export_csv' ) ); ?>"><?php echo __( 'Export CSV', SH_CD_SLUG ); ?></a>
112 - </div>
113 - </div>
114 - </div>
115 67 </div>
116 68 </div>
117 69 </div>
118 70 <br class="clear">
@@ -126,9 +78,9 @@
126 78 $( '#select_csv').on('click', function( event ){
127 79
128 80 event.preventDefault();
129 81
130 - <?php if ( false === sh_cd_is_premium() ) : ?>
82 + <?php if ( false === SH_CD_IS_PREMIUM ) : ?>
131 83 alert( '<?php echo __( "Please upgrade to bulk import shortcodes via CSV.", SH_CD_SLUG ); ?>' );
132 84 return;
133 85 <?php else: ?>
134 86