Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created March 27, 2020 16:41
Show Gist options
  • Save jchristopher/92fc91ec2c3cb57febd9f8e5680abf20 to your computer and use it in GitHub Desktop.
Save jchristopher/92fc91ec2c3cb57febd9f8e5680abf20 to your computer and use it in GitHub Desktop.
Check whether a SearchWP Engine has non-WP_Post Sources
<?php
// Check whether a SearchWP Engine has non-WP_Post Sources.
$engine = new \SearchWP\Engine( 'supplemental' );
$sources = array_keys( $engine->get_sources() );
$non_wp_post_sources = array_filter( $sources, function( $source ) {
return 0 !== strpos( $source, 'post' . SEARCHWP_SEPARATOR );
} );
if ( empty( $non_wp_post_sources ) ) {
// Engine has only WP_Post-based Sources.
} else {
// Engine has $non_wp_post_sources.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment