Prune_Logs::add_purge_settings()

Add field to the settings page


Source

File: src/core/admin/class-prune-logs.php

	public function add_purge_settings() {
		?>
		<div class="wrap">
			<div class="uo-settings">
				<div class="uo-settings-content">
					<form class="uo-settings-content-form" method="POST" action="options.php">
						<?php
						wp_nonce_field( 'automator_manual_purge_days_nonce', 'automator_manual_purge_days_nonce' );
						$date  = get_option( 'automator_last_manual_prune_date', '' );
						$class = ! empty( $date ) ? ' uo-setting--active' : '';
						$section_header_content = '';
						if ( ! empty( $date ) ) {
							$section_header_content = esc_html( sprintf( '%s %s', esc_html__( 'Action performed on:', 'uncanny-automator' ), gmdate( get_option( 'date_format' ), $date ) ) );
						}
						?>
						<?php if ( ! empty( $section_header_content ) ){ ?> 
							<div class="uo-settings-content-header<?php echo esc_html( $class ); ?>">
								<?php echo $section_header_content; ?>
							</div>
						<?php } ?>
						
						<div class="uo-settings-content-top">
							<div class="uo-settings-content-info">
								<div class="uo-settings-content-title">
									<?php esc_html_e( 'Prune activity logs', 'uncanny-automator' ); ?>
								</div>
								<div class="uo-settings-content-description">
									<?php esc_html_e( 'Enter a number of days below to delete recipe log entries older than the specified number of days. Logs will only be deleted for recipes that are not In Progress.', 'uncanny-automator' ); ?>
								</div>
								<div class="uo-settings-content-form">
									<label
										for="automator_manual_purge_days"><?php esc_html_e( 'Enter value in days', 'uncanny-automator' ); ?></label>
									<input id="automator_manual_purge_days" name="automator_manual_purge_days"
										   type="number"
										   class="uo-admin-input"
										   value="<?php echo esc_attr( get_option( 'automator_manual_purge_days', '' ) ); ?>"
										   placeholder="10" min="0" max="365" step="1"
										   required="required"/>
								</div>
							</div>
						</div>
						<div class="uo-settings-content-footer">
							<button type="submit" name="uap_automator_purgedays_save"
									class="uo-settings-btn uo-settings-btn--primary">
								<?php esc_html_e( 'Delete logs', 'uncanny-automator' ); ?>
							</button>
						</div>
					</form>
				</div>
			</div>
		</div>
		<?php
	}