Skip to content

Commit

Permalink
Merge pull request #748 from xwp/bugfix/issue-741
Browse files Browse the repository at this point in the history
Add setting to keep records indefinitely
  • Loading branch information
Luke Carbis committed Sep 1, 2015
2 parents 2f9c6d5 + be819d6 commit 9f0bbdb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions classes/class-admin.php
Expand Up @@ -643,6 +643,10 @@ public function purge_scheduled_action() {
$options = (array) get_option( 'wp_stream', array() );
}

if ( isset( $options['general_keep_records_indefinitely'] ) || ! isset( $options['general_records_ttl'] ) ) {
return;
}

$days = $options['general_records_ttl'];
$date = new DateTime( 'now', $timezone = new DateTimeZone( 'UTC' ) );

Expand Down
12 changes: 10 additions & 2 deletions classes/class-settings.php
Expand Up @@ -236,13 +236,21 @@ public function get_fields() {
'title' => esc_html__( 'Keep Records for', 'stream' ),
'type' => 'number',
'class' => 'small-text',
'desc' => esc_html__( 'Maximum number of days to keep activity records. Leave blank to keep records forever.', 'stream' ),
'desc' => esc_html__( 'Maximum number of days to keep activity records.', 'stream' ),
'default' => 30,
'min' => 0,
'min' => 1,
'max' => 999,
'step' => 1,
'after_field' => esc_html__( 'days', 'stream' ),
),
array(
'name' => 'keep_records_indefinitely',
'title' => esc_html__( 'Keep Records Indefinitely', 'stream' ),
'type' => 'checkbox',
'desc' => sprintf( '<strong>%s</strong> %s', esc_html__( 'Not recommended.', 'stream' ), esc_html__( 'Purging old records helps to keep your WordPress installation running optimally.', 'stream' ) ),
'after_field' => esc_html__( 'Enabled', 'stream' ),
'default' => 0,
),
),
),
'exclude' => array(
Expand Down
20 changes: 20 additions & 0 deletions ui/js/settings.js
Expand Up @@ -233,6 +233,26 @@ jQuery( function( $ ) {

initSettingsSelect2();

var keepRecordsIndefinitely = $( '#wp_stream\\[general_keep_records_indefinitely\\]' ),
keepRecordsFor = $( '#wp_stream_general_records_ttl' ),
keepRecordsForRow = keepRecordsFor.closest( 'tr' );

function toggleKeepRecordsFor() {
if ( keepRecordsIndefinitely.is( ':checked' ) ) {
keepRecordsFor.prop( 'disabled', true );
keepRecordsForRow.contents().fadeTo( 250, 0.25 );
} else {
keepRecordsFor.prop( 'disabled', false );
keepRecordsForRow.contents().fadeTo( 250, 1.0 );
}
}

keepRecordsIndefinitely.on( 'change', function() {
toggleKeepRecordsFor();
});

toggleKeepRecordsFor();

$( '#exclude_rules_new_rule' ).on( 'click', function() {
var $excludeList = $( 'table.stream-exclude-list' );

Expand Down

0 comments on commit 9f0bbdb

Please sign in to comment.