page.php
75 lines
| 1 | <?php |
| 2 | /** |
| 3 | * the view for the import & export page |
| 4 | */ |
| 5 | |
| 6 | class_exists( 'Advanced_Ads', false ) || exit(); |
| 7 | |
| 8 | ?><div class="wrap"> |
| 9 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
| 10 | <?php |
| 11 | foreach( $messages as $_message ) : ?> |
| 12 | <div class="<?php echo $_message[0] === 'error' ? 'error' : 'updated'; ?>"><p><?php echo $_message[1]; ?></p></div> |
| 13 | <?php endforeach; ?> |
| 14 | |
| 15 | |
| 16 | <h2><?php _e( 'Export', 'advanced-ads' ); ?></h2> |
| 17 | <p><?php _e( 'When you click the button below Advanced Ads will create an XML file for you to save to your computer.', 'advanced-ads' ); ?></p> |
| 18 | |
| 19 | <form method="post" action=""> |
| 20 | <fieldset> |
| 21 | <input type="hidden" name="action" value="export" /> |
| 22 | <?php wp_nonce_field( 'advads-export' ); ?> |
| 23 | <p><label><input type="checkbox" name="content[]" value="ads" checked="checked" /> <?php _e( 'Ads', 'advanced-ads' ); ?></label></p> |
| 24 | <p><label><input type="checkbox" name="content[]" value="groups" checked="checked" /> <?php _e( 'Groups', 'advanced-ads' ); ?></label></p> |
| 25 | <p><label><input type="checkbox" name="content[]" value="placements" checked="checked" /> <?php _e( 'Placements', 'advanced-ads' ); ?></label></p> |
| 26 | <p><label><input type="checkbox" name="content[]" value="options" checked="checked" /> <?php _e( 'Options', 'advanced-ads' ); ?></label></p> |
| 27 | </fieldset> |
| 28 | <?php submit_button( __( 'Download Export File', 'advanced-ads' ) ); ?> |
| 29 | </form> |
| 30 | |
| 31 | |
| 32 | |
| 33 | <h2><?php _e( 'Import', 'advanced-ads' ); ?></h2> |
| 34 | <?php |
| 35 | // filter the maximum allowed upload size for import files |
| 36 | $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
| 37 | $size = size_format( $bytes ); |
| 38 | $upload_dir = wp_upload_dir(); |
| 39 | ?> |
| 40 | |
| 41 | <form enctype="multipart/form-data" id="import-upload-form" method="post" action=""> |
| 42 | <?php wp_nonce_field( 'advads-import' ); ?> |
| 43 | <fieldset> |
| 44 | <p><label><input class="advads_import_type" type="radio" name="import_type" value="xml_file" checked="checked" /> <?php _e( 'Choose an XML file', 'advanced-ads' ); ?></label></p> |
| 45 | <p><label><input class="advads_import_type" type="radio" name="import_type" value="xml_content" /> <?php _e( 'Copy an XML content', 'advanced-ads' ); ?></label></p> |
| 46 | </fieldset> |
| 47 | |
| 48 | <div id="advads_xml_file"> |
| 49 | <?php |
| 50 | if ( ! empty( $upload_dir['error'] ) ) : ?> |
| 51 | <p class="advads-error-message"> |
| 52 | <?php _e( 'Before you can upload your import file, you will need to fix the following error:', 'advanced-ads' ); ?> |
| 53 | <strong><?php echo $upload_dir['error']; ?>guu</strong> |
| 54 | </p> |
| 55 | <?php else: ?> |
| 56 | <p> |
| 57 | <input type="file" id="upload" name="import" size="25" /> (<?php printf( __( 'Maximum size: %s', 'advanced-ads' ), $size ); ?>) |
| 58 | <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> |
| 59 | </p> |
| 60 | <?php endif; ?> |
| 61 | </div> |
| 62 | <div id="advads_xml_content" style="display:none;"> |
| 63 | <p><textarea id="xml_textarea" name="xml_textarea" rows="10" cols="20" class="large-text code"></textarea></p> |
| 64 | </div> |
| 65 | <?php submit_button( __( 'Start import', 'advanced-ads' ), 'primary' ); ?> |
| 66 | </form> |
| 67 | |
| 68 | </div> |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 |