Skip to content

Instantly share code, notes, and snippets.

@goranseric
Forked from bhwebworks/stream-filter-v1.php
Created October 17, 2015 03:53
Show Gist options
  • Save goranseric/9680e6e739e9811e39fa to your computer and use it in GitHub Desktop.
Save goranseric/9680e6e739e9811e39fa to your computer and use it in GitHub Desktop.
Prevent unwanted results from appearing in (future) Stream records
<?php
// Prevent unwanted results from appearing in (future) Stream records - v 1.x
add_filter( 'wp_stream_record_array', 'bhww_core_wp_stream_filter_record_array', 10, 1 );
function bhww_core_wp_stream_filter_record_array( $recordarr ) {
// BackupBuddy (iThemes) entries
$context = 'settings';
$option = 'ithemes-updater-cache';
if ( isset( $recordarr['contexts'][ $context ] ) && $option == $recordarr['meta']['option'] ) {
$recordarr = array();
}
// WP Help entries
$context = 'wp-help';
$singular_name = 'help document';
if ( isset( $recordarr['contexts'][ $context ] ) && $singular_name == $recordarr['meta']['singular_name'] ) {
$recordarr = array();
}
return $recordarr;
}
<?php
// Prevent unwanted results from appearing in (future) Stream records - v 2.x
add_filter( 'wp_stream_record_array', 'bhww_core_wp_stream_filter_record_array', 10, 1 );
function bhww_core_wp_stream_filter_record_array( $recordarr ) {
if ( ! isset( $recordarr[0] ) )
return array();
// BackupBuddy (iThemes) entries
if ( 'settings' === $recordarr[0]['connector'] && isset( $recordarr[0]['stream_meta']['option'] ) && 'ithemes-updater-cache' === $recordarr[0]['stream_meta']['option'] )
return array();
// WP Help entries
if ( 'wp-help' === $recordarr[0]['context'] && isset( $recordarr[0]['stream_meta']['singular_name'] ) && 'help document' == $recordarr[0]['stream_meta']['singular_name'] )
return array();
// All other entries
return $recordarr;
}
<?php
// Prevent unwanted results from appearing in (future) Stream records - v 3.x
add_filter( 'wp_stream_record_array', 'bhww_core_wp_stream_filter_record_array', 10, 1 );
function bhww_core_wp_stream_filter_record_array( $recordarr ) {
if ( ! isset( $recordarr ) )
return array();
// BackupBuddy (iThemes) entries
if ( 'Settings' === $recordarr['connector'] && isset( $recordarr['meta']['option'] ) && 'ithemes-updater-cache' === $recordarr['meta']['option'] )
return array();
if ( 'Settings' === $recordarr['connector'] && isset( $recordarr['meta']['option'] ) && 'pb_backupbuddy_notifications' === $recordarr['meta']['option'] )
return array();
// Jetpack Protect entries
if ( 'Settings' === $recordarr['connector'] && isset( $recordarr['meta']['option'] ) && 'jetpack_protect_blocked_attempts' === $recordarr['meta']['option'] )
return array();
// WP Help entries
if ( 'wp-help' === $recordarr['context'] && isset( $recordarr['meta']['singular_name'] ) && 'help document' == $recordarr['meta']['singular_name'] )
return array();
// All other entries
return $recordarr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment