<?php

/**
 * Tools tab – Download logs.
 *
 * @package northmill-online-shared
 */
declare (strict_types=1);
namespace Northmill_Online_Shared_Sync;

/**
 * View parameters.
 *
 * @var array $params
 */
\defined('ABSPATH') || exit;
if ($params['is_plugin']) {
    $only_package_checkbox_text = \__('Only download logs from this plugin.', 'northmill-online-shared');
} else {
    $only_package_checkbox_text = \__('Only download logs from this theme.', 'northmill-online-shared');
}
$only_package_checkbox_text .= ' ' . \__('If this is unchecked, logs from any other installed Northmill plugins and themes will be included.', 'northmill-online-shared');
?>
<div class="wrap">
	<h1><?php 
\esc_html_e('Download logs', 'northmill-online-shared');
?></h1>
	<?php 
if (!$params['archive_available']) {
    ?>
		<div class="notice notice-error inline">
			<p>
				<?php 
    \esc_html_e('Log download is unavailable. Neither the PHP zip extension nor the Phar extension is enabled on this server. Please contact your hosting provider to enable one of them.', 'northmill-online-shared');
    ?>
			</p>
		</div>
	<?php 
} else {
    ?>
		<form method="post" action="<?php 
    echo \esc_url(\admin_url('admin-post.php'));
    ?>">
			<?php 
    \wp_nonce_field($params['admin_post_action'], $params['admin_post_nonce']);
    ?>
			<input type="hidden" name="action" value="<?php 
    echo \esc_attr($params['admin_post_action']);
    ?>">

			<p>
				<label>
					<input
							type="checkbox"
							name="limit_30_days"
							value="1"
							checked
					>
					<?php 
    \esc_html_e('Limit logs to the last 30 days', 'northmill-online-shared');
    ?>
				</label>
			</p>

			<p>
				<label>
					<input
							type="checkbox"
							name="only_package"
							value="1"
					>
					<?php 
    echo \esc_html($only_package_checkbox_text);
    ?>
				</label>
			</p>

			<p>
				<label>
					<input
							type="checkbox"
							name="include_fatal_errors"
							value="1"
							checked
					>
					<?php 
    \esc_html_e('Include fatal-errors.log files', 'northmill-online-shared');
    ?>
				</label>
			</p>

			<p>
				<button type="submit" class="button button-primary">
					<?php 
    \esc_html_e('Download logs', 'northmill-online-shared');
    ?>
				</button>
			</p>
		</form>
	<?php 
}
?>
</div>
<?php 
