- API …", and ADLY's app name is "ADLY". */ public static function keys_connected() { if (self::connected()) { return false; } $cached = get_transient('adly_shop_keys_connected'); if ($cached !== false) { return $cached === 'yes'; } global $wpdb; // WooCommerce has no function that lists its REST keys; the answer is cached for an hour. // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $found = (bool) $wpdb->get_var($wpdb->prepare( "SELECT key_id FROM {$wpdb->prefix}woocommerce_api_keys WHERE description LIKE %s LIMIT 1", $wpdb->esc_like('ADLY - ') . '%' )); set_transient('adly_shop_keys_connected', $found ? 'yes' : 'no', HOUR_IN_SECONDS); return $found; } public static function clear() { delete_option(self::OPTION); } }