function wpforms_doing_scheduled_action(): bool {
return class_exists( Tasks::class ) && Tasks::is_executing();
* Determines whether search functionality is enabled for Choices.js elements in the admin area.
* @param array $data Data to be displayed in the dropdown.
function wpforms_choices_js_is_search_enabled( $data ): string {
* Filter max number of items at which no search box is displayed.
* @param int $count Max items count.
return count( $data ) >= apply_filters( 'wpforms_choices_js_is_search_enabled_max_limit', 20 ) ? 'true' : 'false';
* Check if a form is a template.
* @param int|WP_Post $form Form ID or object.
* @return bool True if the form is a template.
function wpforms_is_form_template( $form ): bool {
$template_post_type = 'wpforms-template';
if ( $form instanceof WP_Post ) {
return $form->post_type === $template_post_type;
return $template_post_type === get_post_type( $form );
* Checks if the current screen is using the block editor.
* @return bool True if the current screen is using the block editor, false otherwise.
function wpforms_is_block_editor(): bool {
$screen = get_current_screen();
return $screen && method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor();
* Check for the editor page.
* @return bool True if the page is in the editor, false otherwise.
function wpforms_is_editor_page(): bool {
// phpcs:disable WordPress.Security.NonceVerification
$rest_request = defined( 'REST_REQUEST' ) && REST_REQUEST;
$context = isset( $_REQUEST['context'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['context'] ) ) : '';
$post_action = isset( $_POST['action'] ) ? sanitize_text_field( wp_unslash( $_POST['action'] ) ) : '';
$get_action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
$is_gutenberg = $rest_request && $context === 'edit';
$is_elementor = $post_action === 'elementor_ajax' || $get_action === 'elementor';
$is_divi = wpforms_is_divi_editor();
// phpcs:enable WordPress.Security.NonceVerification
return $is_gutenberg || $is_elementor || $is_divi;
* Determines whether the current context is the Divi editor.
function wpforms_is_divi_editor(): bool {
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
return ! empty( $_GET['et_fb'] ) || ( isset( $_POST['action'] ) && sanitize_key( $_POST['action'] ) === 'wpforms_divi_preview' );