<commit_before><?php
namespace Podlove\Settings\Expert\Tab;
use \Podlove\Settings\Settings;
use \Podlove\Settings\Expert\Tab;

class Tracking extends Tab {

	public function init() {

		add_settings_section(
			/* $id 		 */ 'podlove_settings_episode',
			/* $title 	 */ __( '', 'podlove' ),	
			/* $callback */ function () {
				echo '<h3>' . __( 'Episode Tracking Settings', 'podlove' ) . '</h3>';
				?>
				<style type="text/css">
				.form-table .aligned-radio { display: table; margin-bottom: 10px; }
				.form-table .aligned-radio .row { display: table-row; }
				.form-table .aligned-radio .row > div { display: table-cell; }
				</style>
				<?php
			},
			/* $page	 */ Settings::$pagehook	
		);

		add_settings_field(
			/* $id       */ 'podlove_setting_tracking',
			/* $title    */ sprintf(
				'<label for="mode">%s</label>',
				__( 'Tracking Mode', 'podlove' )
			),
			/* $callback */ function () {
				?>
				<label class="aligned-radio">
					<div class="row">
						<div>
							<input name="podlove_tracking[mode]" id="mode" type="radio" value="0" <?php checked( \Podlove\get_setting( 'tracking', 'mode' ), 0 ) ?> />
						</div>
						<div>
							<?php echo sprintf(
								'<div><strong>%s</strong><br>%s</div>',
								__( 'No Tracking', 'podlove' ),
								__( 'Original file URLs are presented to users and clients. No download-data is tracked.', 'podlove' )
							); ?>
						</div>
					</div>
				</label>
				
				<label class="aligned-radio">
					<div class="row">
						<div>
							<input name="podlove_tracking[mode]" id="mode" type="radio" value="ptm" <?php checked( \Podlove\get_setting( 'tracking', 'mode' ), 'ptm' ) ?> />
						</div>
						<div>
							<?php echo sprintf(
								'<div><strong>%s</strong><br>%s</div>',
								__( 'Tracking URL Parameters', 'podlove' ),
								__( 'Original file URLs are extended by tracking parameters before presenting them to users and clients. 
									This is useful if you are using your server log files for download analytics. 
									No download-data is tracked.', 'podlove' )
							); ?>
						</div>
					</div>
				</label>

				<label class="aligned-radio">
					<div class="row">
						<div>
							<input name="podlove_tracking[mode]" id="mode" type="radio" value="ptm_analytics" <?php checked( \Podlove\get_setting( 'tracking', 'mode' ), 'ptm_analytics' ) ?> />
						</div>
						<div>
							<?php echo sprintf(
								'<div><strong>%s</strong><br>%s</div>',
								__( 'Tracking URL Parameters &amp; Analytics', 'podlove' ),
								__( 'Instead of the original file URLs, users and clients see a link that points to the Publisher. 
									The Publisher logs the download intent and redirects the user to the original file. 
									That way the Publisher is able to generate download statistics. ', 'podlove' )
							); ?>
						</div>
					</div>
				</label>
				<?php
			},
			/* $page     */ Settings::$pagehook,  
			/* $section  */ 'podlove_settings_episode'
		);

		add_settings_field(
			/* $id       */ 'podlove_setting_tracking_ips',
			/* $title    */ sprintf(
				'<label for="enable_ips">%s</label>',
				__( 'Save IP addresses', 'podlove' )
			),
			/* $callback */ function () {
				?>
				<label>
					<input name="podlove_tracking[enable_ips]" id="enable_ips" type="radio" value="1" <?php checked( \Podlove\get_setting( 'tracking', 'enable_ips' ), 1 ) ?> /> <?php echo __( 'Save IP addresses (allows geo tracking).', 'podlove' ) ?>
				</label>
				<br>
				<label>
					<input name="podlove_tracking[enable_ips]" id="enable_ips" type="radio" value="0" <?php checked( \Podlove\get_setting( 'tracking', 'enable_ips' ), 0 ) ?> /> <?php echo __( 'Do not save IP addresses.', 'podlove' ) ?>
				</label>
				<?php
			},
			/* $page     */ Settings::$pagehook,  
			/* $section  */ 'podlove_settings_episode'
		);

		add_settings_field(
			/* $id       */ 'podlove_setting_tracking_dnt',
			/* $title    */ sprintf(
				'<label for="respect_dnt">%s</label>',
				__( 'Respect DNT Header', 'podlove' )
			),
			/* $callback */ function () {
				?>
				<label>
					<input name="podlove_tracking[respect_dnt]" id="respect_dnt" type="radio" value="1" <?php checked( \Podlove\get_setting( 'tracking', 'respect_dnt' ), 1 ) ?> /> <?php echo __( 'Respect DNT.', 'podlove' ) ?>
				</label>
				<br>
				<label>
					<input name="podlove_tracking[respect_dnt]" id="respect_dnt" type="radio" value="0" <?php checked( \Podlove\get_setting( 'tracking', 'respect_dnt' ), 0 ) ?> /> <?php echo __( 'Ignore DNT.', 'podlove' ) ?>
				</label>
				<p>
					<?php echo sprintf(
						__('Respect the %sDO NOT TRACK-Header%s of clients. When it is set, neither IP nor user agent will be saved if the client sends a DNT header.', 'podlove'),
						'<a href="http://en.wikipedia.org/wiki/Do_not_track" target="_blank">',
						'</a>'
					); ?>
				</p>
				<?php
			},
			/* $page     */ Settings::$pagehook,  
			/* $section  */ 'podlove_settings_episode'
		);

		register_setting( Settings::$pagehook, 'podlove_tracking' );
	}

}<commit_msg>tracking settings: hide settings based on context<commit_after><?php
namespace Podlove\Settings\Expert\Tab;
use \Podlove\Settings\Settings;
use \Podlove\Settings\Expert\Tab;

class Tracking extends Tab {

	public function init() {

		add_settings_section(
			/* $id 		 */ 'podlove_settings_episode',
			/* $title 	 */ __( '', 'podlove' ),	
			/* $callback */ function () {
				echo '<h3>' . __( 'Download Tracking & Analytics Settings', 'podlove' ) . '</h3>';
				?>
				<style type="text/css">
				.form-table .aligned-radio { display: table; margin-bottom: 10px; }
				.form-table .aligned-radio .row { display: table-row; }
				.form-table .aligned-radio .row > div { display: table-cell; }
				</style>

				<script type="text/javascript">
				jQuery(function($) {
					function manage_tracking_setting_visibility() {
						var input = $("input[name='podlove_tracking[mode]']:checked"),
							value = input.val(),
							toggleElements = $("#enable_ips, #respect_dnt").closest("tr");

						if (value == "ptm_analytics") {
							toggleElements.show();
						} else {
							toggleElements.hide();
						}
					}

					$("input[name='podlove_tracking[mode]']").on("change", function(e) {
						manage_tracking_setting_visibility();
					});

					manage_tracking_setting_visibility();
				});
				</script>
				<?php
			},
			/* $page	 */ Settings::$pagehook	
		);

		add_settings_field(
			/* $id       */ 'podlove_setting_tracking',
			/* $title    */ sprintf(
				'<label for="mode">%s</label>',
				__( 'Tracking Mode', 'podlove' )
			),
			/* $callback */ function () {
				?>
				<label class="aligned-radio">
					<div class="row">
						<div>
							<input name="podlove_tracking[mode]" type="radio" value="0" <?php checked( \Podlove\get_setting( 'tracking', 'mode' ), 0 ) ?> />
						</div>
						<div>
							<?php echo sprintf(
								'<div><strong>%s</strong><br>%s</div>',
								__( 'No Tracking', 'podlove' ),
								__( 'Original file URLs are presented to users and clients. No download-data is tracked.', 'podlove' )
							); ?>
						</div>
					</div>
				</label>
				
				<label class="aligned-radio">
					<div class="row">
						<div>
							<input name="podlove_tracking[mode]" type="radio" value="ptm" <?php checked( \Podlove\get_setting( 'tracking', 'mode' ), 'ptm' ) ?> />
						</div>
						<div>
							<?php echo sprintf(
								'<div><strong>%s</strong><br>%s</div>',
								__( 'Tracking URL Parameters', 'podlove' ),
								__( 'Original file URLs are extended by tracking parameters before presenting them to users and clients. 
									This is useful if you are using your server log files for download analytics. 
									No download-data is tracked.', 'podlove' )
							); ?>
						</div>
					</div>
				</label>

				<label class="aligned-radio">
					<div class="row">
						<div>
							<input name="podlove_tracking[mode]" type="radio" value="ptm_analytics" <?php checked( \Podlove\get_setting( 'tracking', 'mode' ), 'ptm_analytics' ) ?> />
						</div>
						<div>
							<?php echo sprintf(
								'<div><strong>%s</strong><br>%s</div>',
								__( 'Tracking URL Parameters &amp; Analytics', 'podlove' ),
								__( 'Instead of the original file URLs, users and clients see a link that points to the Publisher. 
									The Publisher logs the download intent and redirects the user to the original file. 
									That way the Publisher is able to generate download statistics. ', 'podlove' )
							); ?>
						</div>
					</div>
				</label>
				<?php
			},
			/* $page     */ Settings::$pagehook,  
			/* $section  */ 'podlove_settings_episode'
		);

		add_settings_field(
			/* $id       */ 'podlove_setting_tracking_ips',
			/* $title    */ sprintf(
				'<label id="enable_ips">%s</label>',
				__( 'Save IP addresses', 'podlove' )
			),
			/* $callback */ function () {
				?>
				<label>
					<input name="podlove_tracking[enable_ips]" type="radio" value="1" <?php checked( \Podlove\get_setting( 'tracking', 'enable_ips' ), 1 ) ?> /> <?php echo __( 'Save IP addresses (allows geo tracking).', 'podlove' ) ?>
				</label>
				<br>
				<label>
					<input name="podlove_tracking[enable_ips]" type="radio" value="0" <?php checked( \Podlove\get_setting( 'tracking', 'enable_ips' ), 0 ) ?> /> <?php echo __( 'Do not save IP addresses.', 'podlove' ) ?>
				</label>
				<?php
			},
			/* $page     */ Settings::$pagehook,  
			/* $section  */ 'podlove_settings_episode'
		);

		add_settings_field(
			/* $id       */ 'podlove_setting_tracking_dnt',
			/* $title    */ sprintf(
				'<label id="respect_dnt">%s</label>',
				__( 'Respect DNT Header', 'podlove' )
			),
			/* $callback */ function () {
				?>
				<label>
					<input name="podlove_tracking[respect_dnt]" type="radio" value="1" <?php checked( \Podlove\get_setting( 'tracking', 'respect_dnt' ), 1 ) ?> /> <?php echo __( 'Respect DNT.', 'podlove' ) ?>
				</label>
				<br>
				<label>
					<input name="podlove_tracking[respect_dnt]" type="radio" value="0" <?php checked( \Podlove\get_setting( 'tracking', 'respect_dnt' ), 0 ) ?> /> <?php echo __( 'Ignore DNT.', 'podlove' ) ?>
				</label>
				<p>
					<?php echo sprintf(
						__('Respect the %sDO NOT TRACK-Header%s of clients. When it is set, neither IP nor user agent will be saved if the client sends a DNT header.', 'podlove'),
						'<a href="http://en.wikipedia.org/wiki/Do_not_track" target="_blank">',
						'</a>'
					); ?>
				</p>
				<?php
			},
			/* $page     */ Settings::$pagehook,  
			/* $section  */ 'podlove_settings_episode'
		);

		register_setting( Settings::$pagehook, 'podlove_tracking' );
	}

}
{'fraction_non_alphanumeric': 0.1791885800150263, 'fraction_numerical': 0.002629601803155522, 'mean_word_length': 2.7708923512747874, 'pattern_counts': {'":': 0, '<': 185, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7571953', 'n_tokens_mistral': 4523, 'n_tokens_neox': 3476, 'n_words': 828}