Skip to content

Instantly share code, notes, and snippets.

@bhwebworks
Last active October 22, 2019 12:05
Show Gist options
  • Save bhwebworks/11384243 to your computer and use it in GitHub Desktop.
Save bhwebworks/11384243 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 ( 'jetpack' === $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;
}
@greggh
Copy link

greggh commented Oct 18, 2019

Thank you! Using that info I solved it. Just had to change the match to a bit more fuzzy. The WP Rocket and Imagify ones append those keys to the end of their 'option', so they are all unique. But they all start with the same code:

// imagify
if ( 'settings' === $data_array['connector'] && isset( $data_array['meta']['option'] ) && strpos($data_array['meta']['option'], 'imagify_optimize_media_batch') !== false )
	return array();

// WP Rocket
if ( 'settings' === $data_array['connector'] && isset( $data_array['meta']['option'] ) && strpos($data_array['meta']['option'], 'rocket_preload_batch') !== false )
	return array();

@bhwebworks
Copy link
Author

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment