Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories

Register::count()publicWC 1.0

Indicates the number of approved directories that are enabled (or disabled, if optional param $enabled is set to false).

Method of the class: Register{}

No Hooks.

Return

Int.

Usage

$Register = new Register();
$Register->count( $enabled ): int;
$enabled(true|false)
Controls whether enabled or disabled directory rules are counted.
Default: true

Register::count() code WC 8.7.0

public function count( bool $enabled = true ): int {
	global $wpdb;
	$table = $this->get_table();

	return (int) $wpdb->get_var(
		$wpdb->prepare(
			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
			"SELECT COUNT(*) FROM {$table} WHERE enabled = %d",
			$enabled ? 1 : 0
		)
	);
}