Created
March 27, 2020 16:41
-
-
Save jchristopher/92fc91ec2c3cb57febd9f8e5680abf20 to your computer and use it in GitHub Desktop.
Check whether a SearchWP Engine has non-WP_Post Sources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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