import-history.php
1 year ago
other-plugin-importer.php
1 week ago
page.php
3 months ago
plugin-settings.php
3 months ago
tab-importers.php
3 months ago
tab-status.php
3 months ago
tab-version.php
3 months ago
plugin-settings.php
106 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Render Importers |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.50.0 |
| 8 | */ |
| 9 | |
| 10 | use AdvancedAds\Utilities\WordPress; |
| 11 | use AdvancedAds\Framework\Utilities\Params; |
| 12 | |
| 13 | $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
| 14 | $size = size_format( $bytes ); |
| 15 | $upload_dir = wp_upload_dir(); |
| 16 | ?> |
| 17 | <div class="advads-plugin-importer"> |
| 18 | <header> |
| 19 | <h2 class="advads-h2"><?php esc_html_e( 'Plugin Settings', 'advanced-ads' ); ?></h2> |
| 20 | <p class="text-sm"> |
| 21 | <?php |
| 22 | esc_html_e( 'Import or export your Advanced Ads settings, This option is useful for replicating the ads configuration across multiple websites.', 'advanced-ads' ); |
| 23 | WordPress::manual_link( 'https://wpadvancedads.com/manual/import-export/', 'tools-quicklinks' ); |
| 24 | ?> |
| 25 | |
| 26 | </p> |
| 27 | </header> |
| 28 | <div class="advads-tabs-wrap"> |
| 29 | <input type="radio" id="advads-import" name="plugin-importers" checked> |
| 30 | <input type="radio" id="advads-export" name="plugin-importers"> |
| 31 | |
| 32 | <div class="advads-tab-nav"> |
| 33 | <label for="advads-import"> |
| 34 | <span class="dashicons dashicons-database-import"></span> |
| 35 | <span><?php esc_html_e( 'Import Settings', 'advanced-ads' ); ?></span> |
| 36 | </label> |
| 37 | <label for="advads-export"> |
| 38 | <span class="dashicons dashicons-database-export"></span> |
| 39 | <span><?php esc_html_e( 'Export Settings', 'advanced-ads' ); ?></span> |
| 40 | </label> |
| 41 | </div> |
| 42 | |
| 43 | <form id="import" class="advads-tab-content" enctype="multipart/form-data" method="post" action="<?php echo esc_url( Params::server( 'REQUEST_URI' ) ); ?>#import"> |
| 44 | <div class="advads-tab-content-body"> |
| 45 | <input type="hidden" name="action" value="advads_import"> |
| 46 | <input type="hidden" name="importer" value="xml"> |
| 47 | <?php wp_nonce_field( 'advads_import' ); ?> |
| 48 | <p> |
| 49 | <label for="advads-xml-file-input"> |
| 50 | <input id="advads-xml-file-input" data-toggle="#advads-xml-file, #advads-xml-content" type="radio" name="import_type" value="xml_file" checked="checked" /> |
| 51 | <?php esc_html_e( 'Choose an XML file', 'advanced-ads' ); ?> |
| 52 | </label> |
| 53 | </p> |
| 54 | <p> |
| 55 | <label for="advads-xml-content-input"> |
| 56 | <input id="advads-xml-content-input" data-toggle="#advads-xml-file, #advads-xml-content" type="radio" name="import_type" value="xml_content" /> |
| 57 | <?php esc_html_e( 'Copy an XML content', 'advanced-ads' ); ?> |
| 58 | </label> |
| 59 | </p> |
| 60 | |
| 61 | <div id="advads_xml_file"> |
| 62 | <?php if ( ! empty( $upload_dir['error'] ) ) : ?> |
| 63 | <p class="advads-notice-inline advads-error"> |
| 64 | <?php esc_html_e( 'Before you can upload your import file, you will need to fix the following error:', 'advanced-ads' ); ?> |
| 65 | <strong><?php echo $upload_dir['error']; // phpcs:ignore ?>guu</strong> |
| 66 | </p> |
| 67 | <?php else : ?> |
| 68 | <p> |
| 69 | <input type="file" id="upload" name="import" size="25" /> (<?php /* translators: %s maximum size allowed */ printf( __( 'Maximum size: %s', 'advanced-ads' ), $size ); // phpcs:ignore ?>) |
| 70 | <input type="hidden" name="max_file_size" value="<?php echo $bytes; // phpcs:ignore ?>" /> |
| 71 | </p> |
| 72 | <?php endif; ?> |
| 73 | </div> |
| 74 | <div id="advads-xml-content" class="hidden"> |
| 75 | <p><textarea id="xml_textarea" name="xml_textarea" rows="10" cols="20" class="large-text code"></textarea></p> |
| 76 | <?php WordPress::manual_link( 'https://wpadvancedads.com/manual/import-export/', 'tools-quicklinks', __( 'Ad Templates', 'advanced-ads' ) ); ?> |
| 77 | </div> |
| 78 | </div> |
| 79 | <div class="advads-tab-content-footer"> |
| 80 | <button class="button button-primary button-large" type="submit"> |
| 81 | <?php esc_html_e( 'Start Import', 'advanced-ads' ); ?> |
| 82 | </button> |
| 83 | </div> |
| 84 | </form> |
| 85 | |
| 86 | <form id="export" class="advads-tab-content" method="post" action="<?php echo esc_url( Params::server( 'REQUEST_URI' ) ); ?>#export"> |
| 87 | <div class="advads-tab-content-body"> |
| 88 | <input type="hidden" name="action" value="advads_export"> |
| 89 | <?php wp_nonce_field( 'advads_export' ); ?> |
| 90 | <p class="text-sm"><?php esc_html_e( 'When you click the button below Advanced Ads will create an XML file for you to save to your computer.', 'advanced-ads' ); ?></p> |
| 91 | <ul class="advads-checkbox-list mb-0"> |
| 92 | <li><label><input type="checkbox" name="content[]" value="ads" checked="checked" /> <?php esc_html_e( 'Ads', 'advanced-ads' ); ?></label></li> |
| 93 | <li><label><input type="checkbox" name="content[]" value="groups" checked="checked" /> <?php esc_html_e( 'Groups', 'advanced-ads' ); ?></label></li> |
| 94 | <li><label><input type="checkbox" name="content[]" value="placements" checked="checked" /> <?php esc_html_e( 'Placements', 'advanced-ads' ); ?></label></li> |
| 95 | <li><label><input type="checkbox" name="content[]" value="options" /> <?php esc_html_e( 'Options', 'advanced-ads' ); ?></label></li> |
| 96 | </ul> |
| 97 | </div> |
| 98 | <div class="advads-tab-content-footer"> |
| 99 | <button class="button button-primary button-large" type="submit"> |
| 100 | <?php esc_html_e( 'Download Export File', 'advanced-ads' ); ?> |
| 101 | </button> |
| 102 | </div> |
| 103 | </form> |
| 104 | </div> |
| 105 | </div> |
| 106 |