get_var( "SHOW TABLES LIKE '" . $wpdb->esc_like( $table ) . "'" ); } /** * Get the fully qualified sync store table names. * * @return string[] Sync store table names. */ public static function required_tables(): array { global $wpdb; return array( $wpdb->prefix . self::SYNC_JOURNAL_TABLE, $wpdb->prefix . self::STORED_DIGEST_TABLE, $wpdb->prefix . self::MUTATIONS_TABLE, ); } /** * Get sync store tables that have not been installed. * * @return string[] Missing sync store table names. */ public static function missing_tables(): array { $missing_tables = array(); foreach ( self::required_tables() as $table ) { if ( ! self::table_exists( $table ) ) { $missing_tables[] = $table; } } return $missing_tables; } /** * Check whether all required sync store tables exist. */ public static function is_healthy(): bool { return 0 === \count( self::missing_tables() ); } /** * Get the error returned when the sync store is unavailable. */ public static function unhealthy_error(): \WP_Error { return new \WP_Error( 'wcpos_sync_unavailable', __( 'The WCPOS sync store is not installed yet (initialising or a schema install failed). Retry shortly.', 'woocommerce-pos' ), array( 'status' => 503, 'retry_after_seconds' => self::RETRY_AFTER_SECONDS, ) ); } }