* @param string $name Class name or an alias.
public function obj( string $name ): ?object {
return $this->registry[ $name ] ?? null;
* Get the list of all custom tables starting with `wpforms_*`.
* @return array List of table names.
public function get_existing_custom_tables(): array {
// phpcs:ignore WPForms.Formatting.EmptyLineBeforeReturn.RemoveEmptyLineBeforeReturnStatement
return DB::get_existing_custom_tables();
* Whether the current instance of the plugin is a paid version, or free.
public function is_pro(): bool {
* Filters whether the current plugin version is pro.
* @param bool $pro Whether the current plugin version is pro.
return (bool) apply_filters( 'wpforms_allow_pro_version', $this->pro );
* Whether the current request is restricted heartbeat.
public static function is_restricted_heartbeat(): bool {
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$action = $_POST['action'] ?? '';
if ( $action !== 'heartbeat' || ! wp_doing_ajax() ) {
$screen_id = sanitize_key( $_POST['screen_id'] ?? '' );
$data = array_map( 'sanitize_text_field', $_POST['data'] ?? [] );
// phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
* Filters the screen ids where the heartbeat is allowed.
* @param array $allowed_screen_ids Screen IDs where the heartbeat is allowed.
$allowed_screen_ids = (array) apply_filters( 'wpforms_heartbeat_allowed_screen_ids', self::HEARTBEAT_ALLOWED_SCREEN_IDS );
// Allow heartbeat requests on specific screens.
if ( in_array( $screen_id, $allowed_screen_ids, true ) ) {
* Filters whether the current request is restricted heartbeat.
* @param bool $is_restricted Whether the current request is restricted heartbeat.
* @param string $screen_id Screen ID.
* @param array $data Heartbeat request data.
return (bool) apply_filters( 'wpforms_is_restricted_heartbeat', true, $screen_id, $data );
// phpcs:ignore Universal.Namespaces.DisallowCurlyBraceSyntax.Forbidden, Universal.Namespaces.DisallowDeclarationWithoutName.Forbidden, Universal.Namespaces.OneDeclarationPerFile.MultipleFound
// Define `wpforms()` function only if it's not the restricted heartbeat request.
if ( ! WPForms\WPForms::is_restricted_heartbeat() ) {
* The function which returns the one WPForms instance.
* @return WPForms\WPForms
function wpforms(): WPForms\WPForms { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
return WPForms\WPForms::instance();
* Adding an alias for backward-compatibility with plugins
* that still use class_exists( 'WPForms' )
* instead of function_exists( 'wpforms' ), which is preferred.
* In 1.5.0 we removed support for PHP 5.2
* and moved the former WPForms class to a namespace: WPForms\WPForms.
class_alias( 'WPForms\WPForms', 'WPForms' );