PluginProbe ʕ •ᴥ•ʔ
Custom Sidebars – Dynamic Sidebar Classic Widget Area Manager / 3.0.7.1
Custom Sidebars – Dynamic Sidebar Classic Widget Area Manager v3.0.7.1
trunk 2.1.2.0 3.0.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3 3.31 3.32 3.35 3.36 3.37 3.38
custom-sidebars / views / import.php
custom-sidebars / views Last commit date
col-sidebars.php 9 years ago import.php 9 years ago metabox.php 9 years ago quick-edit.php 9 years ago widgets-delete.php 10 years ago widgets-editor.php 10 years ago widgets-export.php 10 years ago widgets-location.php 9 years ago widgets.php 10 years ago
import.php
333 lines
1 <?php
2 /**
3 * PRO section: Show interface for import preview.
4 */
5
6 global $wp_version;
7
8 $import = CustomSidebarsExport::get_import_data();
9
10 $date_format = get_option( 'date_format' ) . ', ' . get_option( 'time_format' );
11 $theme = wp_get_theme();
12 $current_sidebars = CustomSidebars::get_custom_sidebars();
13 $theme_sidebars = CustomSidebars::get_sidebars();
14 $current_keys = array();
15 foreach ( $current_sidebars as $c_sidebar ) {
16 $current_keys[] = $c_sidebar['id'];
17 }
18
19 $csb_info = get_plugin_data( CSB_PLUGIN );
20
21 /**
22 * Helper function used only in this view.
23 * It renders a list with sidebar-replacement details
24 */
25 function list_sidebar_replacement( $label, $list ) {
26 $import = CustomSidebarsExport::get_import_data();
27 $theme_sidebars = CustomSidebars::get_sidebars();
28
29 if ( is_array( $list ) ) {
30 foreach ( $list as $from_id => $to_id ) {
31 $from = $theme_sidebars[ $from_id ];
32 $to = array();
33 if ( isset( $theme_sidebars[ $to_id ] ) ) {
34 $to = $theme_sidebars[ $to_id ];
35 } else {
36 $to = $import['sidebars'][ $to_id ];
37 }
38 ?>
39 <tr>
40 <th scope="row"><?php echo esc_html( $label ); ?></th>
41 <td><?php echo esc_html( $from['name'] ); ?></td>
42 <td><i class="dashicons dashicons-arrow-right-alt hint"></i></td>
43 <td><?php echo esc_html( $to['name'] ); ?></td>
44 </tr>
45 <?php
46 }
47 }
48 }
49 ?>
50 <div>
51 <div class="wpmui-form">
52 <?php if ( ! empty( $import ) ) : ?>
53 <?php
54 /* *****************************************************************
55 *
56 * Show basic infos about the WordPress configuration at time of
57 * the export.
58 */
59 ?>
60 <h2 class="no-pad-top"><?php _e( 'Import', 'custom-sidebars' ); ?></h2>
61 <div class="show-infos">
62 <i class="dashicons dashicons-info"></i>
63 <div class="export-infos" style="display:none">
64 <table cellspacing="1" cellpadding="4" class="csb-export-head">
65 <tbody>
66 <tr>
67 <th><?php _e( 'Filename', 'custom-sidebars' ); ?></th>
68 <td colspan="2"><?php echo esc_html( @$import['meta']['filename'] ); ?></td>
69 </tr>
70 <tr>
71 <th><?php _e( 'Exported on', 'custom-sidebars' ); ?></th>
72 <td colspan="2"><?php echo esc_html( ' ' . date( $date_format, $import['meta']['created'] ) ); ?></td>
73 </tr>
74 </tbody>
75 </table>
76
77 <div class="section"><?php _e( 'WordPress settings', 'custom-sidebars' ); ?></div>
78 <table cellspacing="1" cellpadding="4" class="csb-export-head">
79 <thead>
80 <tr>
81 <th></th>
82 <td>Export</td>
83 <td>Current</td>
84 </tr>
85 </thead>
86 <tbody>
87 <tr>
88 <th><?php _e( 'WordPress version', 'custom-sidebars' ); ?></th>
89 <td><?php echo esc_html( $import['meta']['wp_version'] ); ?></td>
90 <td><?php echo esc_html( $wp_version ); ?></td>
91 </tr>
92 <tr>
93 <th><?php _e( 'Plugin version', 'custom-sidebars' ); ?></th>
94 <td><?php echo esc_html( $import['meta']['csb_version'] ); ?></td>
95 <td><?php echo esc_html( @$csb_info['Version'] ); ?></td>
96 </tr>
97 <tr>
98 <th><?php _e( 'Theme', 'custom-sidebars' ); ?></th>
99 <td><?php echo esc_html( $import['meta']['theme_name'] . ' (' . $import['meta']['theme_version'] . ')' ); ?></td>
100 <td><?php echo esc_html( $theme->get( 'Name' ) . ' (' . $theme->get( 'Version' ) . ')' ); ?></td>
101 </tr>
102 </tbody>
103 </table>
104 </div>
105 </div>
106
107 <?php if ( ! empty( $import['meta']['description'] ) ) : ?>
108 <pre><?php echo esc_html( stripslashes( $import['meta']['description'] ) ); ?></pre>
109 <?php endif; ?>
110
111
112 <form class="frm-import csb-form">
113 <input type="hidden" name="do" value="import" />
114
115
116 <?php
117 /* *****************************************************************
118 *
119 * List all sidebars in the import file
120 */
121 $alternate = '';
122 ?>
123 <h3 class="title"><?php _e( 'Custom Sidebars', 'custom-sidebars' ); ?></h3>
124 <p>
125 <?php _e( 'Mark the sidebars that you want to import.', 'custom-sidebars' ); ?>
126 </p>
127 <p>
128 <label for="import-widgets">
129 <input type="checkbox" id="import-widgets" name="import_widgets" />
130 <?php _e( 'Also import all widgets of the selected sidebars.', 'custom-sidebars' ); ?>
131 </label>
132 </p>
133 <table class="widefat">
134 <thead>
135 <tr>
136 <th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" /></th>
137 <th scope="col" id="name" class="manage-column column-name"><?php _e( 'Name', 'custom-sidebars' ); ?></th>
138 <th scope="col" id="description" class="manage-column column-description"><?php _e( 'Description', 'custom-sidebars' ); ?></th>
139 <th scope="col" id="note" class="manage-column column-note"><?php _e( 'Note', 'custom-sidebars' ); ?></th>
140 <th scope="col" id="widgets" class="manage-column column-widgets" style="display:none"><?php _e( 'Widgets', 'custom-sidebars' ); ?></th>
141 </tr>
142 </thead>
143 <tbody>
144 <?php
145 foreach ( $import['sidebars'] as $sidebar ) {
146 $alternate = ('' == $alternate ? 'alternate' : '');
147 $note = __( 'New sidebar will be created', 'custom-sidebars' );
148 if ( in_array( $sidebar['id'], $current_keys ) ) {
149 $note = __( 'Existing sidebar will be replaced!', 'custom-sidebars' );
150 }
151 $import_sidebar = @$import['widgets'][ $sidebar['id'] ];
152 if ( ! is_array( $import_sidebar ) ) {
153 $import_sidebar = array();
154 }
155 $id = sprintf( 'import_sb_id_%s', $sidebar['id'] );
156 ?>
157 <tr class="<?php echo esc_attr( $alternate ); ?>">
158 <th scope="row" class="check-column">
159 <input type="checkbox" name="import_sb_<?php echo esc_attr( $sidebar['id'] ); ?>" id="<?php echo esc_attr( $id ); ?>"/>
160 </th>
161 <td class="name column-name"><label for="<?php echo esc_attr( $id ); ?>"><?php echo esc_html( $sidebar['name'] ); ?></label></td>
162 <td class="description column-description"><?php echo esc_html( $sidebar['description'] ); ?></td>
163 <td class="note column-note"><?php echo esc_html( $note ); ?></td>
164 <td class="widgets column-widgets" style="display:none">
165 <?php
166 if ( count( $import_sidebar ) ) {
167 echo '<ul>';
168 foreach ( $import_sidebar as $key => $data ) {
169 printf( '<li>%s</li>', esc_html( $data['name'] ) );
170 }
171 echo '</ul>';
172 } else {
173 echo '-';
174 }
175 ?>
176 </td>
177 </tr>
178 <?php
179 }
180
181
182 /* *****************************************************************
183 *
184 * List all default theme sidebars that exist in the import file
185 */
186
187 foreach ( $theme_sidebars as $sidebar ) {
188 if ( isset( $import['widgets'][ $sidebar['id'] ] ) ) {
189 $alternate = ('' == $alternate ? 'alternate' : '');
190 $import_sidebar = @$import['widgets'][ $sidebar['id'] ];
191 if ( ! is_array( $import_sidebar ) ) {
192 $import_sidebar = array();
193 }
194 if ( ! count( $import_sidebar ) ) {
195 continue;
196 }
197 $id = sprintf( 'import_sb_id_%s', $sidebar['id'] );
198 ?>
199 <tr class="import-widgets <?php echo esc_attr( $alternate ); ?>" style="display: none">
200 <th scope="row" class="check-column">
201 <input type="checkbox" name="import_sb_<?php echo esc_attr( $sidebar['id'] ); ?>" id="<?php echo esc_attr( $id ); ?>"/>
202 </th>
203 <td class="name column-name"><label for="<?php echo esc_attr( $id ); ?>"><?php echo esc_html( $sidebar['name'] ); ?></label></td>
204 <td class="description column-description"><?php echo esc_html( $sidebar['description'] ); ?></td>
205 <td><em><?php _e( '(Theme sidebar)', 'custom-sidebars' ); ?></em></td>
206 <td class="widgets column-widgets">
207 <?php
208 if ( count( $import_sidebar ) ) {
209 echo '<ul>';
210 foreach ( $import_sidebar as $key => $data ) {
211 printf( '<li>%s</li>', esc_html( $data['name'] ) );
212 }
213 echo '</ul>';
214 } else {
215 echo '-';
216 }
217 ?>
218 </td>
219 </tr>
220 <?php
221 }
222 }
223 ?>
224 </tbody>
225 </table>
226 <?php
227 /* *****************************************************************
228 *
229 * Show the custom sidebar configuration
230 */
231 ?>
232 <p>&nbsp;</p>
233 <h3 class="title"><?php _e( 'Configuration', 'custom-sidebars' ); ?>
234 <div class="show-infos">
235 <i class="dashicons dashicons-info"></i>
236 <div class="export-infos" style="display:none">
237 <div class="section"><?php _e( 'Replaceable sidebars', 'custom-sidebars' ); ?></div>
238 <table cellspacing="1" cellpadding="4" class="csb-export-head">
239 <tr>
240 <th scope="row"><?php _e( 'Replaceable Sidebars', 'custom-sidebars' ); ?></th>
241 <td>
242 <?php foreach ( $import['options']['modifiable'] as $sb_id ) : ?>
243 <?php echo esc_html( $theme_sidebars[ $sb_id ]['name'] ); ?><br />
244 <?php endforeach; ?>
245 </td>
246 </tr>
247 </table>
248
249 <?php /* single-posttype */ ?>
250 <div class="section"><?php _e( 'By post type', 'custom-sidebars' ); ?></div>
251 <table cellspacing="1" cellpadding="4" class="csb-export-head">
252 <?php
253 $list = @$import['options']['post_type_single'];
254 foreach ( $list as $key => $values ) {
255 $type = get_post_type_object( $key );
256 if ( ! count( $values ) ) { continue; }
257 list_sidebar_replacement( $type->labels->name, $values );
258 }
259 ?>
260 </table>
261
262 <?php /* archive-posttype */ ?>
263 <div class="section"><?php _e( 'Post-type archives', 'custom-sidebars' ); ?></div>
264 <table cellspacing="1" cellpadding="4" class="csb-export-head">
265 <?php
266 $list = @$import['options']['post_type_archive'];
267 foreach ( $list as $key => $values ) {
268 $type = get_post_type_object( $key );
269 if ( ! count( $values ) ) { continue; }
270 list_sidebar_replacement( $type->labels->name, $values );
271 }
272 ?>
273 </table>
274
275 <?php /* single-category */ ?>
276 <div class="section"><?php _e( 'By category', 'custom-sidebars' ); ?></div>
277 <table cellspacing="1" cellpadding="4" class="csb-export-head">
278 <?php
279 $list = @$import['options']['category_single'];
280 foreach ( $list as $key => $values ) {
281 $cat = get_category( $key );
282 if ( ! count( $values ) ) { continue; }
283 list_sidebar_replacement( $cat->name, $values );
284 }
285 ?>
286 </table>
287
288 <?php /* archive-category */ ?>
289 <div class="section"><?php _e( 'Category archives', 'custom-sidebars' ); ?></div>
290 <table cellspacing="1" cellpadding="4" class="csb-export-head">
291 <?php
292 $list = @$import['options']['category_archive'];
293 foreach ( $list as $key => $values ) {
294 $cat = get_category( $key );
295 if ( ! count( $values ) ) { continue; }
296 list_sidebar_replacement( $cat->name, $values );
297 }
298 ?>
299 </table>
300
301 <?php /* special pages */ ?>
302 <div class="section"><?php _e( 'Special pages', 'custom-sidebars' ); ?></div>
303 <table cellspacing="1" cellpadding="4" class="csb-export-head">
304 <?php
305 list_sidebar_replacement( __( 'Main blog page', 'custom-sidebars' ), $import['options']['blog'] );
306 list_sidebar_replacement( __( 'Date archives', 'custom-sidebars' ), $import['options']['date'] );
307 list_sidebar_replacement( __( 'Author archives', 'custom-sidebars' ), $import['options']['authors'] );
308 list_sidebar_replacement( __( 'Tag archives', 'custom-sidebars' ), $import['options']['tags'] );
309 list_sidebar_replacement( __( 'Search results page', 'custom-sidebars' ), $import['options']['search'] );
310 ?>
311 </table>
312 </div>
313 </div>
314 </h3>
315
316 <p>
317 <label for="import-config">
318 <input type="checkbox" id="import-config" name="import_plugin_config" />
319 <?php _e( 'Replace the current plugin configuration with the imported configuration.', 'custom-sidebars' ); ?>
320 </label>
321 </p>
322
323 <input type="hidden" name="import_data" value="<?php echo esc_attr( base64_encode( json_encode( (object) $import ) ) ); ?>" />
324 <p class="buttons">
325 <button type="button" class="btn-cancel button-link">Cancel</button>
326 <button class="button-primary btn-import"><i class="dashicons dashicons-migrate"></i> Import selected items</button>
327 </p>
328 </form>
329
330 <?php endif; ?>
331 </div>
332 </div>
333