WordPress at Your Fingertips
function is not described

WC_Tracker::post_contains_text() public WC 1.0

Search a specific post for text content.

{} It's a method of the class: WC_Tracker{}

No Hooks.

Return

String. 'Yes' if post contains $text (otherwise 'No').

Usage

$result = WC_Tracker::post_contains_text( $post_id, $text );
$post_id(int) (required)
The id of the post to search.
$text(string) (required)
The text to search for.

Code of WC_Tracker::post_contains_text() WC 5.9.0

public static function post_contains_text( $post_id, $text ) {
	global $wpdb;

	// Search for the text anywhere in the post.
	$wildcarded = "%{$text}%";

	$result = $wpdb->get_var(
		$wpdb->prepare(
			"
			SELECT COUNT( * ) FROM {$wpdb->prefix}posts
			WHERE ID=%d
			AND {$wpdb->prefix}posts.post_content LIKE %s
			",
			array( $post_id, $wildcarded )
		)
	);

	return ( '0' !== $result ) ? 'Yes' : 'No';
}