From 4b20bd9336f67f5bbd19fdf79d821d4361849ef0 Mon Sep 17 00:00:00 2001 From: Faishal Saiyed Date: Mon, 24 Mar 2014 03:45:41 +0530 Subject: [PATCH 1/6] Apply filter to query args Fix #355 --- includes/admin.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/admin.php b/includes/admin.php index f35a26dfc..1fd1b5586 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -808,8 +808,16 @@ public static function gather_updated_items( $last_id, $query = null ) { // Filter default $query = wp_parse_args( $query, $default ); + // Remove excluded records as per settings + add_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); + // Run query - return stream_query( $query ); + $items = stream_query( $query ); + + // Remove filter added before + remove_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); + + return $items; } /** From ecef750c15ec905f4c8867cd2fc77bf3cd519551 Mon Sep 17 00:00:00 2001 From: Faishal Saiyed Date: Mon, 24 Mar 2014 05:01:21 +0530 Subject: [PATCH 2/6] Fix #354 WordPress 3.9 wpdb::prepare empty placeholder issue --- includes/query.php | 62 +++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/includes/query.php b/includes/query.php index fc582b241..8e9d8e0dd 100644 --- a/includes/query.php +++ b/includes/query.php @@ -129,64 +129,70 @@ public function query( $args ) { /** * PARSE __IN PARAM FAMILY */ - if ( $args['record_greater_than'] ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.ID > %d", (int) $args['record_greater_than'] ); + if ( $args[ 'record_greater_than' ] ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.ID > %d", (int)$args[ 'record_greater_than' ] ); } - if ( $args['record__in'] ) { - $record__in = implode( ',', array_filter( (array) $args['record__in'], 'is_numeric' ) ); - if ( $record__in ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.ID IN ($record__in)", '' ); + if ( $args[ 'record__in' ] ) { + $record__in = array_filter( (array)$args[ 'record__in' ], 'is_numeric' ); + $record__in_format = '(' . substr( str_repeat( ',%d', count( $record__in ) ), 1 ) . ')'; + if ( ! empty( $record__in ) ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.ID IN {$record__in_format}", $record__in ); } } - if ( $args['record__not_in'] ) { - $record__not_in = implode( ',', array_filter( (array) $args['record__not_in'], 'is_numeric' ) ); - if ( strlen( $record__not_in ) ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.ID NOT IN ($record__not_in)", '' ); + if ( $args[ 'record__not_in' ] ) { + $record__not_in = array_filter( (array)$args[ 'record__not_in' ], 'is_numeric' ); + $record__not_in_format = '(' . substr( str_repeat( ',%d', count( $record__not_in ) ), 1 ) . ')'; + if ( ! empty( $record__not_in ) ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.ID NOT IN {$record__not_in_format}", $record__not_in ); } } - if ( $args['record_parent'] ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.parent = %d", (int) $args['record_parent'] ); + if ( $args[ 'record_parent' ] ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.parent = %d", (int)$args[ 'record_parent' ] ); } - if ( $args['record_parent__in'] ) { - $record_parent__in = implode( ',', array_filter( (array) $args['record_parent__in'], 'is_numeric' ) ); - if ( strlen( $record_parent__in ) ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.parent IN ($record_parent__in)", '' ); + if ( $args[ 'record_parent__in' ] ) { + $record_parent__in = array_filter( (array)$args[ 'record_parent__in' ], 'is_numeric' ); + $record_parent__in_format = '(' . substr( str_repeat( ',%d', count( $record_parent__in ) ), 1 ) . ')'; + if ( ! empty( $record_parent__in ) ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.parent IN {$record_parent__in_format}", $record_parent__in ); } } - if ( $args['record_parent__not_in'] ) { - $record_parent__not_in = implode( ',', array_filter( (array) $args['record_parent__not_in'], 'is_numeric' ) ); - if ( strlen( $record_parent__not_in ) ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.parent NOT IN ($record_parent__not_in)", '' ); + if ( $args[ 'record_parent__not_in' ] ) { + $record_parent__not_in = array_filter( (array)$args[ 'record_parent__not_in' ], 'is_numeric' ); + $record_parent__not_in_format = '(' . substr( str_repeat( ',%d', count( $record_parent__not_in ) ), 1 ) . ')'; + if ( ! empty( $record_parent__not_in ) ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.parent NOT IN {$record_parent__not_in_format}", $record_parent__not_in ); } } if ( $args[ 'author__in' ] ) { - $author__in = implode( ',', array_filter( (array)$args[ 'author__in' ], 'is_numeric' ) ); - if ( $author__in ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.author IN ($author__in)", '' ); + $author__in = array_filter( (array)$args[ 'author__in' ], 'is_numeric' ); + $author__in_format = '(' . substr( str_repeat( ',%d', count( $author__in ) ), 1 ) . ')'; + if ( ! empty( $author__in ) ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.author IN {$author__in_format}", $author__in ); } } if ( $args[ 'author__not_in' ] ) { - $author__not_in = implode( ',', array_filter( (array)$args[ 'author__not_in' ], 'is_numeric' ) ); - if ( strlen( $author__not_in ) ) { - $where .= $wpdb->prepare( " AND $wpdb->stream.author NOT IN ($author__not_in)", '' ); + $author__not_in = array_filter( (array)$args[ 'author__not_in' ], 'is_numeric' ); + $author__not_in_format = '(' . substr( str_repeat( ',%d', count( $author__not_in ) ), 1 ) . ')'; + if ( ! empty( $author__not_in ) ) { + $where .= $wpdb->prepare( " AND $wpdb->stream.author NOT IN {$author__not_in_format}", $author__not_in ); } } if ( $args[ 'ip__in' ] ) { - if ( count( $args[ 'ip__in' ] ) > 0 ) { + if ( ! empty( $args[ 'ip__in' ] ) ) { $ip__in = '(' . substr( str_repeat( ',%s', count( $args[ 'ip__in' ] ) ), 1 ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.ip IN {$ip__in}", $args[ 'ip__in' ] ); } } if ( $args[ 'ip__not_in' ] ) { - if ( count( $args[ 'ip__not_in' ] ) > 0 ) { + if ( ! empty( $args[ 'ip__not_in' ] ) ) { $ip__not_in = '(' . substr( str_repeat( ',%s', count( $args[ 'ip__not_in' ] ) ), 1 ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.ip NOT IN {$ip__not_in}", $args[ 'ip__not_in' ] ); } From ce4d569da29ada30007e39b9fc1994461870ea84 Mon Sep 17 00:00:00 2001 From: Faishal Saiyed Date: Tue, 25 Mar 2014 02:48:23 +0530 Subject: [PATCH 3/6] Use array_fill instead of str_repeat #355 --- includes/query.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/query.php b/includes/query.php index 8e9d8e0dd..d0d9cd4e2 100644 --- a/includes/query.php +++ b/includes/query.php @@ -135,7 +135,7 @@ public function query( $args ) { if ( $args[ 'record__in' ] ) { $record__in = array_filter( (array)$args[ 'record__in' ], 'is_numeric' ); - $record__in_format = '(' . substr( str_repeat( ',%d', count( $record__in ) ), 1 ) . ')'; + $record__in_format = '(' . join( ',', array_fill( 0, count( $record__in ), '%d' ) ) . ')'; if ( ! empty( $record__in ) ) { $where .= $wpdb->prepare( " AND $wpdb->stream.ID IN {$record__in_format}", $record__in ); } @@ -143,7 +143,7 @@ public function query( $args ) { if ( $args[ 'record__not_in' ] ) { $record__not_in = array_filter( (array)$args[ 'record__not_in' ], 'is_numeric' ); - $record__not_in_format = '(' . substr( str_repeat( ',%d', count( $record__not_in ) ), 1 ) . ')'; + $record__not_in_format = '(' . join( ',', array_fill( 0, count( $record__not_in ), '%d' ) ) . ')'; if ( ! empty( $record__not_in ) ) { $where .= $wpdb->prepare( " AND $wpdb->stream.ID NOT IN {$record__not_in_format}", $record__not_in ); } @@ -155,7 +155,7 @@ public function query( $args ) { if ( $args[ 'record_parent__in' ] ) { $record_parent__in = array_filter( (array)$args[ 'record_parent__in' ], 'is_numeric' ); - $record_parent__in_format = '(' . substr( str_repeat( ',%d', count( $record_parent__in ) ), 1 ) . ')'; + $record_parent__in_format = '(' . join( ',', array_fill( 0, count( $record_parent__in ), '%d' ) ) . ')'; if ( ! empty( $record_parent__in ) ) { $where .= $wpdb->prepare( " AND $wpdb->stream.parent IN {$record_parent__in_format}", $record_parent__in ); } @@ -163,7 +163,7 @@ public function query( $args ) { if ( $args[ 'record_parent__not_in' ] ) { $record_parent__not_in = array_filter( (array)$args[ 'record_parent__not_in' ], 'is_numeric' ); - $record_parent__not_in_format = '(' . substr( str_repeat( ',%d', count( $record_parent__not_in ) ), 1 ) . ')'; + $record_parent__not_in_format = '(' . join( ',', array_fill( 0, count( $record_parent__not_in ), '%d' ) ) . ')'; if ( ! empty( $record_parent__not_in ) ) { $where .= $wpdb->prepare( " AND $wpdb->stream.parent NOT IN {$record_parent__not_in_format}", $record_parent__not_in ); } @@ -171,7 +171,7 @@ public function query( $args ) { if ( $args[ 'author__in' ] ) { $author__in = array_filter( (array)$args[ 'author__in' ], 'is_numeric' ); - $author__in_format = '(' . substr( str_repeat( ',%d', count( $author__in ) ), 1 ) . ')'; + $author__in_format = '(' . join( ',', array_fill( 0, count( $author__in ), '%d' ) ) . ')'; if ( ! empty( $author__in ) ) { $where .= $wpdb->prepare( " AND $wpdb->stream.author IN {$author__in_format}", $author__in ); } @@ -179,21 +179,21 @@ public function query( $args ) { if ( $args[ 'author__not_in' ] ) { $author__not_in = array_filter( (array)$args[ 'author__not_in' ], 'is_numeric' ); - $author__not_in_format = '(' . substr( str_repeat( ',%d', count( $author__not_in ) ), 1 ) . ')'; + $author__not_in_format = '(' . join( ',', array_fill( 0, count( $author__not_in ), '%d' ) ) . ')'; if ( ! empty( $author__not_in ) ) { $where .= $wpdb->prepare( " AND $wpdb->stream.author NOT IN {$author__not_in_format}", $author__not_in ); } } if ( $args[ 'ip__in' ] ) { if ( ! empty( $args[ 'ip__in' ] ) ) { - $ip__in = '(' . substr( str_repeat( ',%s', count( $args[ 'ip__in' ] ) ), 1 ) . ')'; + $ip__in = '(' . join( ',', array_fill( 0, count( $args[ 'ip__in' ] ), '%s' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.ip IN {$ip__in}", $args[ 'ip__in' ] ); } } if ( $args[ 'ip__not_in' ] ) { if ( ! empty( $args[ 'ip__not_in' ] ) ) { - $ip__not_in = '(' . substr( str_repeat( ',%s', count( $args[ 'ip__not_in' ] ) ), 1 ) . ')'; + $ip__not_in = '(' . join( ',', array_fill( 0, count( $args[ 'ip__not_in' ] ), '%s' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.ip NOT IN {$ip__not_in}", $args[ 'ip__not_in' ] ); } } From c60815dce53bc13c0ff813af1e6fde7989382d55 Mon Sep 17 00:00:00 2001 From: Faishal Saiyed Date: Tue, 25 Mar 2014 03:01:55 +0530 Subject: [PATCH 4/6] Add hide_excluded query args, remove all excluded record filters --- includes/admin.php | 12 ----------- includes/feeds.php | 6 ------ includes/list-table.php | 6 ------ includes/query.php | 44 ++++++++++++++++++++++++++++++++++++++++- includes/settings.php | 36 --------------------------------- 5 files changed, 43 insertions(+), 61 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 1fd1b5586..b3f73e4eb 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -546,14 +546,8 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { 'paged' => $paged, ); - // Remove excluded records as per settings - add_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - $records = stream_query( $args ); - // Remove filter added before - remove_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - if ( ! $records ) { ?>

@@ -808,15 +802,9 @@ public static function gather_updated_items( $last_id, $query = null ) { // Filter default $query = wp_parse_args( $query, $default ); - // Remove excluded records as per settings - add_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - // Run query $items = stream_query( $query ); - // Remove filter added before - remove_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - return $items; } diff --git a/includes/feeds.php b/includes/feeds.php index de94e5efd..109a87a9c 100644 --- a/includes/feeds.php +++ b/includes/feeds.php @@ -145,14 +145,8 @@ public static function feed_template() { 'fields' => isset( $_GET['fields'] ) ? (string) $_GET['fields'] : '', ); - // Remove excluded records as per settings - add_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - $records = stream_query( $args ); - // Remove filter added before - remove_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - $latest_record = isset( $records[0]->created ) ? $records[0]->created : null; $records_admin_url = add_query_arg( diff --git a/includes/list-table.php b/includes/list-table.php index ab43afb0b..693c752c6 100644 --- a/includes/list-table.php +++ b/includes/list-table.php @@ -142,14 +142,8 @@ function get_records() { $args['records_per_page'] = $this->get_items_per_page( 'edit_stream_per_page', 20 ); } - // Remove excluded records as per settings - add_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - $items = stream_query( $args ); - // Remove filter added before - remove_filter( 'stream_query_args', array( 'WP_Stream_Settings', 'remove_excluded_record_filter' ), 10, 1 ); - return $items; } diff --git a/includes/query.php b/includes/query.php index d0d9cd4e2..3632a4c27 100644 --- a/includes/query.php +++ b/includes/query.php @@ -60,10 +60,11 @@ public function query( $args ) { // Fields selection 'fields' => '', 'ignore_context' => null, + //Hide Excluded + 'hide_excluded' => true, ); $args = wp_parse_args( $args, $defaults ); - /** * Filter allows additional arguments to query $args * @@ -72,6 +73,10 @@ public function query( $args ) { */ $args = apply_filters( 'stream_query_args', $args ); + if ( true === $args[ 'hide_excluded' ] ) { + $args = self::add_excluded_record_args( $args ); + } + $join = ''; $where = ''; @@ -311,6 +316,42 @@ public function query( $args ) { return $results; } + /** + * Function will add excluded settings args into stream query + * + * @param $args array query args passed to stream_query + * + * @return array + */ + public static function add_excluded_record_args( $args ) { + // Remove record of excluded connector + if ( empty( $args['connector'] ) ) { + $args['connector__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'connectors' ); + } + + // Remove record of excluded context + if ( empty( $args['context'] ) ) { + $args['context__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'contexts' ); + } + + // Remove record of excluded actions + if ( empty( $args['action'] ) ) { + $args['action__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'actions' ); + } + + // Remove record of excluded author + if ( empty( $args['author'] ) ) { + $args['author__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'authors_and_roles' ); + } + + // Remove record of excluded ip + if ( empty( $args['ip'] ) ) { + $args['ip__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'ip_addresses' ); + } + + return $args; + } + } function stream_query( $args = array() ) { @@ -366,3 +407,4 @@ function existing_records( $column, $table = '' ) { return isset( WP_Stream_Connectors::$term_labels[ $column ] ) ? WP_Stream_Connectors::$term_labels[ $column ] : array(); } } + diff --git a/includes/settings.php b/includes/settings.php index 0b909d7a3..4b6621c12 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -775,40 +775,4 @@ public static function updated_option_ttl_remove_records( $old_value, $new_value do_action( 'wp_stream_auto_purge' ); } } - - /** - * Function will add excluded settings args into stream query - * - * @param $args array query args passed to stream_query - * - * @return array - */ - public static function remove_excluded_record_filter( $args ) { - // Remove record of excluded connector - if ( empty( $args['connector'] ) ) { - $args['connector__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'connectors' ); - } - - // Remove record of excluded context - if ( empty( $args['context'] ) ) { - $args['context__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'contexts' ); - } - - // Remove record of excluded actions - if ( empty( $args['action'] ) ) { - $args['action__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'actions' ); - } - - // Remove record of excluded author - if ( empty( $args['author'] ) ) { - $args['author__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'authors_and_roles' ); - } - - // Remove record of excluded ip - if ( empty( $args['ip'] ) ) { - $args['ip__not_in'] = WP_Stream_Settings::get_excluded_by_key( 'ip_addresses' ); - } - - return $args; - } } From 559eec57c9cf4cf00e75ba7d7cde23ac4b66d4e1 Mon Sep 17 00:00:00 2001 From: Faishal Saiyed Date: Tue, 25 Mar 2014 03:51:26 +0530 Subject: [PATCH 5/6] Fix array_fill warnings --- includes/query.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/includes/query.php b/includes/query.php index 3632a4c27..0c037f2c2 100644 --- a/includes/query.php +++ b/includes/query.php @@ -139,17 +139,17 @@ public function query( $args ) { } if ( $args[ 'record__in' ] ) { - $record__in = array_filter( (array)$args[ 'record__in' ], 'is_numeric' ); - $record__in_format = '(' . join( ',', array_fill( 0, count( $record__in ), '%d' ) ) . ')'; + $record__in = array_filter( (array)$args[ 'record__in' ], 'is_numeric' ); if ( ! empty( $record__in ) ) { + $record__in_format = '(' . join( ',', array_fill( 0, count( $record__in ), '%d' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.ID IN {$record__in_format}", $record__in ); } } if ( $args[ 'record__not_in' ] ) { - $record__not_in = array_filter( (array)$args[ 'record__not_in' ], 'is_numeric' ); - $record__not_in_format = '(' . join( ',', array_fill( 0, count( $record__not_in ), '%d' ) ) . ')'; + $record__not_in = array_filter( (array)$args[ 'record__not_in' ], 'is_numeric' ); if ( ! empty( $record__not_in ) ) { + $record__not_in_format = '(' . join( ',', array_fill( 0, count( $record__not_in ), '%d' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.ID NOT IN {$record__not_in_format}", $record__not_in ); } } @@ -159,33 +159,33 @@ public function query( $args ) { } if ( $args[ 'record_parent__in' ] ) { - $record_parent__in = array_filter( (array)$args[ 'record_parent__in' ], 'is_numeric' ); - $record_parent__in_format = '(' . join( ',', array_fill( 0, count( $record_parent__in ), '%d' ) ) . ')'; + $record_parent__in = array_filter( (array)$args[ 'record_parent__in' ], 'is_numeric' ); if ( ! empty( $record_parent__in ) ) { + $record_parent__in_format = '(' . join( ',', array_fill( 0, count( $record_parent__in ), '%d' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.parent IN {$record_parent__in_format}", $record_parent__in ); } } if ( $args[ 'record_parent__not_in' ] ) { - $record_parent__not_in = array_filter( (array)$args[ 'record_parent__not_in' ], 'is_numeric' ); - $record_parent__not_in_format = '(' . join( ',', array_fill( 0, count( $record_parent__not_in ), '%d' ) ) . ')'; + $record_parent__not_in = array_filter( (array)$args[ 'record_parent__not_in' ], 'is_numeric' ); if ( ! empty( $record_parent__not_in ) ) { + $record_parent__not_in_format = '(' . join( ',', array_fill( 0, count( $record_parent__not_in ), '%d' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.parent NOT IN {$record_parent__not_in_format}", $record_parent__not_in ); } } if ( $args[ 'author__in' ] ) { - $author__in = array_filter( (array)$args[ 'author__in' ], 'is_numeric' ); - $author__in_format = '(' . join( ',', array_fill( 0, count( $author__in ), '%d' ) ) . ')'; + $author__in = array_filter( (array)$args[ 'author__in' ], 'is_numeric' ); if ( ! empty( $author__in ) ) { + $author__in_format = '(' . join( ',', array_fill( 0, count( $author__in ), '%d' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.author IN {$author__in_format}", $author__in ); } } if ( $args[ 'author__not_in' ] ) { - $author__not_in = array_filter( (array)$args[ 'author__not_in' ], 'is_numeric' ); - $author__not_in_format = '(' . join( ',', array_fill( 0, count( $author__not_in ), '%d' ) ) . ')'; + $author__not_in = array_filter( (array)$args[ 'author__not_in' ], 'is_numeric' ); if ( ! empty( $author__not_in ) ) { + $author__not_in_format = '(' . join( ',', array_fill( 0, count( $author__not_in ), '%d' ) ) . ')'; $where .= $wpdb->prepare( " AND $wpdb->stream.author NOT IN {$author__not_in_format}", $author__not_in ); } } From f63de5c349f5c92145fb5f03818bdc2f63b2924d Mon Sep 17 00:00:00 2001 From: Faishal Saiyed Date: Thu, 27 Mar 2014 03:06:45 +0530 Subject: [PATCH 6/6] Add visibility setting in exclude tab & use as default value for hide_excluded in query --- includes/query.php | 3 +-- includes/settings.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/includes/query.php b/includes/query.php index 0c037f2c2..808103535 100644 --- a/includes/query.php +++ b/includes/query.php @@ -21,7 +21,6 @@ public static function get_instance() { */ public function query( $args ) { global $wpdb; - $defaults = array( // Pagination params 'records_per_page' => 10, @@ -61,7 +60,7 @@ public function query( $args ) { 'fields' => '', 'ignore_context' => null, //Hide Excluded - 'hide_excluded' => true, + 'hide_excluded' => ( WP_Stream_Settings::$options[ 'exclude_hide_previous_records' ] === 0 ) ? false : true, ); $args = wp_parse_args( $args, $defaults ); diff --git a/includes/settings.php b/includes/settings.php index 4b6621c12..160d84734 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -305,6 +305,16 @@ public static function get_fields() { 'default' => array(), 'nonce' => 'stream_get_ips', ), + array( + 'name' => 'hide_previous_records', + 'title' => __( 'Visibility', 'stream' ), + 'type' => 'checkbox', + 'desc' => sprintf( + __( 'When Checked, all post records that match the excluded rules above will be hidden from view', 'stream' ) + ), + 'after_field' => __( 'Hide Previous Records' ), + 'default' => 0, + ), ), ), );