Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Last active March 14, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtsternberg/0802e7e9f80bfacf9d0e2ca20bc830b9 to your computer and use it in GitHub Desktop.
Save jtsternberg/0802e7e9f80bfacf9d0e2ca20bc830b9 to your computer and use it in GitHub Desktop.
Filter OptinMonster campaigns loaded into WordPress by name
<?php
function filter_om_campaigns_by_name( $campaigns, $save ) {
// Make sure this is the refresh request and that we have data.
if ( ! isset( $campaigns->success ) && ! empty( $campaigns ) ) {
// Loop through the campaigns
foreach ( (array) $campaigns as $slug => $campaign ) {
// If we don't have a title
// OR title does not start with 'SOME PREFIX: '
if ( ! isset( $campaign->title ) || 0 !== strpos( $campaign->title, 'SOME PREFIX: ') ) {
// then we do NOT bring this into WordPress.
unset( $campaigns->$slug );
}
}
}
return $campaigns;
}
add_filter( 'optin_monster_pre_store_options', 'filter_om_campaigns_by_name', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment