Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-conte.../plugins/wpforms-.../includes/function...
File: checks.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Helper functions to perform various checks across the core plugin and addons.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 1.8.0
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
// phpcs:disable Generic.Commenting.DocComment.MissingShort
[7] Fix | Delete
/** @noinspection PhpUndefinedNamespaceInspection */
[8] Fix | Delete
/** @noinspection PhpUndefinedClassInspection */
[9] Fix | Delete
// phpcs:enable Generic.Commenting.DocComment.MissingShort
[10] Fix | Delete
[11] Fix | Delete
use WPForms\Vendor\TrueBV\Punycode;
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Check if a string is a valid URL.
[15] Fix | Delete
*
[16] Fix | Delete
* @since 1.0.0
[17] Fix | Delete
* @since 1.5.8 Changed the pattern used to validate the URL.
[18] Fix | Delete
*
[19] Fix | Delete
* @param string $url Input URL.
[20] Fix | Delete
*
[21] Fix | Delete
* @return bool
[22] Fix | Delete
* @noinspection RegExpUnnecessaryNonCapturingGroup
[23] Fix | Delete
* @noinspection RegExpRedundantEscape
[24] Fix | Delete
*/
[25] Fix | Delete
function wpforms_is_url( $url ): bool {
[26] Fix | Delete
[27] Fix | Delete
// The pattern taken from https://gist.github.com/dperini/729294.
[28] Fix | Delete
// It is the best choice according to the https://mathiasbynens.be/demo/url-regex.
[29] Fix | Delete
$pattern = '%^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\x{00a1}-\x{ffff}][a-z0-9\x{00a1}-\x{ffff}_-]{0,62})?[a-z0-9\x{00a1}-\x{ffff}]\.)+(?:[a-z\x{00a1}-\x{ffff}]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$%iu';
[30] Fix | Delete
[31] Fix | Delete
if ( preg_match( $pattern, trim( $url ) ) ) {
[32] Fix | Delete
return true;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
return false;
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Verify that an email is valid.
[40] Fix | Delete
* See the linked RFC.
[41] Fix | Delete
*
[42] Fix | Delete
* @see https://www.rfc-editor.org/rfc/inline-errata/rfc3696.html
[43] Fix | Delete
*
[44] Fix | Delete
* @since 1.7.3
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $email Email address to verify.
[47] Fix | Delete
*
[48] Fix | Delete
* @return string|false Returns a valid email address on success, false on failure.
[49] Fix | Delete
*/
[50] Fix | Delete
function wpforms_is_email( $email ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded
[51] Fix | Delete
[52] Fix | Delete
static $punycode;
[53] Fix | Delete
[54] Fix | Delete
// Do not allow callables, arrays, and objects.
[55] Fix | Delete
if ( ! is_scalar( $email ) ) {
[56] Fix | Delete
return false;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
// Allow smart tags in the email address.
[60] Fix | Delete
if ( preg_match( '/{.+?}/', $email ) ) {
[61] Fix | Delete
return $email;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
// Email can't be longer than 254 octets,
[65] Fix | Delete
// otherwise it can't be used to send an email address (limitation in the MAIL and RCPT commands).
[66] Fix | Delete
// 1 octet = 8 bits = 1 byte.
[67] Fix | Delete
if ( strlen( $email ) > 254 ) {
[68] Fix | Delete
return false;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
$email_arr = explode( '@', $email );
[72] Fix | Delete
[73] Fix | Delete
if ( count( $email_arr ) !== 2 ) {
[74] Fix | Delete
return false;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
list( $local, $domain ) = $email_arr;
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* RFC requires local part to be no longer than 64 octets.
[81] Fix | Delete
* Punycode library checks for 63 octets.
[82] Fix | Delete
*
[83] Fix | Delete
* @link https://github.com/true/php-punycode/blob/master/src/Punycode.php#L182.
[84] Fix | Delete
*/
[85] Fix | Delete
if ( strlen( $local ) > 63 ) {
[86] Fix | Delete
return false;
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$domain_arr = explode( '.', $domain );
[90] Fix | Delete
[91] Fix | Delete
foreach ( $domain_arr as $domain_label ) {
[92] Fix | Delete
$domain_label = trim( $domain_label );
[93] Fix | Delete
[94] Fix | Delete
if ( ! $domain_label ) {
[95] Fix | Delete
return false;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
// The RFC says: 'A DNS label may be no more than 63 octets long'.
[99] Fix | Delete
if ( strlen( $domain_label ) > 63 ) {
[100] Fix | Delete
return false;
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
if ( ! $punycode ) {
[105] Fix | Delete
$punycode = new Punycode();
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* The wp_mail() uses phpMailer, which uses is_email() as verification callback.
[110] Fix | Delete
* For verification, phpMailer sends the email address where the domain part is punycode encoded only.
[111] Fix | Delete
* We follow here the same principle.
[112] Fix | Delete
*/
[113] Fix | Delete
$email_check = $local . '@' . $punycode->encode( $domain );
[114] Fix | Delete
[115] Fix | Delete
// Other limitations are checked by the native WordPress function is_email().
[116] Fix | Delete
return is_email( $email_check ) ? $local . '@' . $domain : false;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Check whether the string is json-encoded.
[121] Fix | Delete
*
[122] Fix | Delete
* @since 1.7.5
[123] Fix | Delete
*
[124] Fix | Delete
* @param string $value A string.
[125] Fix | Delete
*
[126] Fix | Delete
* @return bool
[127] Fix | Delete
*/
[128] Fix | Delete
function wpforms_is_json( $value ): bool {
[129] Fix | Delete
[130] Fix | Delete
return (
[131] Fix | Delete
is_string( $value ) &&
[132] Fix | Delete
is_array( json_decode( $value, true ) ) &&
[133] Fix | Delete
json_last_error() === JSON_ERROR_NONE
[134] Fix | Delete
);
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Check whether the current page is in AMP mode or not.
[139] Fix | Delete
* We need to check for specific functions, as there is no special AMP header.
[140] Fix | Delete
*
[141] Fix | Delete
* @since 1.4.1
[142] Fix | Delete
*
[143] Fix | Delete
* @param bool $check_theme_support Whether theme support should be checked. Defaults to true.
[144] Fix | Delete
*
[145] Fix | Delete
* @return bool
[146] Fix | Delete
*/
[147] Fix | Delete
function wpforms_is_amp( $check_theme_support = true ): bool {
[148] Fix | Delete
[149] Fix | Delete
$is_amp = false;
[150] Fix | Delete
[151] Fix | Delete
if (
[152] Fix | Delete
// AMP by Automattic; ampforwp.
[153] Fix | Delete
( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) ||
[154] Fix | Delete
// Better AMP.
[155] Fix | Delete
( function_exists( 'is_better_amp' ) && is_better_amp() )
[156] Fix | Delete
) {
[157] Fix | Delete
$is_amp = true;
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
if ( $is_amp && $check_theme_support ) {
[161] Fix | Delete
$is_amp = current_theme_supports( 'amp' );
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
/**
[165] Fix | Delete
* Filters AMP flag.
[166] Fix | Delete
*
[167] Fix | Delete
* @since 1.4.1
[168] Fix | Delete
*
[169] Fix | Delete
* @param bool $is_amp Current page AMP status.
[170] Fix | Delete
*
[171] Fix | Delete
* @return bool
[172] Fix | Delete
*/
[173] Fix | Delete
return (bool) apply_filters( 'wpforms_is_amp', $is_amp );
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Helper function to determine if loading on WPForms related admin page.
[178] Fix | Delete
*
[179] Fix | Delete
* Here we determine if the current administration page is owned/created by
[180] Fix | Delete
* WPForms. This is done in compliance with WordPress best practices for
[181] Fix | Delete
* development, so that we only load required WPForms CSS and JS files on pages
[182] Fix | Delete
* we create. As a result, we do not load our assets admin wide, where they might
[183] Fix | Delete
* conflict with other plugins needlessly, also leading to a better, faster user
[184] Fix | Delete
* experience for our users.
[185] Fix | Delete
*
[186] Fix | Delete
* @since 1.3.9
[187] Fix | Delete
*
[188] Fix | Delete
* @param string $slug Slug identifier for a specific WPForms admin page.
[189] Fix | Delete
* @param string $view Slug identifier for a specific WPForms admin page view ("subpage").
[190] Fix | Delete
*
[191] Fix | Delete
* @return bool
[192] Fix | Delete
*/
[193] Fix | Delete
function wpforms_is_admin_page( $slug = '', $view = '' ): bool {
[194] Fix | Delete
[195] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
[196] Fix | Delete
[197] Fix | Delete
// Check against basic requirements.
[198] Fix | Delete
if (
[199] Fix | Delete
empty( $_REQUEST['page'] ) ||
[200] Fix | Delete
strpos( $_REQUEST['page'], 'wpforms' ) === false ||
[201] Fix | Delete
! is_admin()
[202] Fix | Delete
) {
[203] Fix | Delete
return false;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
// Check against page slug identifier.
[207] Fix | Delete
if (
[208] Fix | Delete
( ! empty( $slug ) && $_REQUEST['page'] !== 'wpforms-' . $slug ) ||
[209] Fix | Delete
( empty( $slug ) && $_REQUEST['page'] === 'wpforms-builder' )
[210] Fix | Delete
) {
[211] Fix | Delete
return false;
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
// Check against sub-level page view.
[215] Fix | Delete
if (
[216] Fix | Delete
! empty( $view ) &&
[217] Fix | Delete
( empty( $_REQUEST['view'] ) || $_REQUEST['view'] !== $view )
[218] Fix | Delete
) {
[219] Fix | Delete
return false;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
[223] Fix | Delete
[224] Fix | Delete
return true;
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
/**
[228] Fix | Delete
* Check if a string is empty.
[229] Fix | Delete
*
[230] Fix | Delete
* @since 1.5.0
[231] Fix | Delete
*
[232] Fix | Delete
* @param string $value String to test.
[233] Fix | Delete
*
[234] Fix | Delete
* @return bool
[235] Fix | Delete
*/
[236] Fix | Delete
function wpforms_is_empty_string( $value ): bool {
[237] Fix | Delete
// phpcs:ignore WPForms.Formatting.EmptyLineBeforeReturn.RemoveEmptyLineBeforeReturnStatement
[238] Fix | Delete
return $value === '';
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
/**
[242] Fix | Delete
* Determine if the request is a rest API call.
[243] Fix | Delete
*
[244] Fix | Delete
* NOTE: The function shouldn't be used before the `rest_api_init` action.
[245] Fix | Delete
*
[246] Fix | Delete
* @since 1.8.8
[247] Fix | Delete
*
[248] Fix | Delete
* @return bool|null True if the request is a REST API call, null if the function is called incorrectly.
[249] Fix | Delete
*/
[250] Fix | Delete
function wpforms_is_rest() {
[251] Fix | Delete
[252] Fix | Delete
// The function is not available, means that `wpforms_is_rest` is called incorrectly.
[253] Fix | Delete
// The possible reason is that the function is called too early, before the `rest-api.php` is loaded.
[254] Fix | Delete
// In this case, we should not proceed with the check.
[255] Fix | Delete
if ( ! function_exists( 'rest_url' ) ) {
[256] Fix | Delete
return null;
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
$rest_url = wp_parse_url( trailingslashit( rest_url() ) );
[260] Fix | Delete
$wpforms_route = $rest_url['path'] !== '/index.php' ? $rest_url['path'] . 'wpforms/' : '/wpforms/';
[261] Fix | Delete
[262] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[263] Fix | Delete
$rest_route = isset( $_GET['rest_route'] ) ? sanitize_text_field( wp_unslash( $_GET['rest_route'] ) ) : '';
[264] Fix | Delete
[265] Fix | Delete
if ( strpos( $rest_route, $wpforms_route ) === 0 ) {
[266] Fix | Delete
return true;
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
$current_url = wp_parse_url( wpforms_current_url() );
[270] Fix | Delete
[271] Fix | Delete
return strpos( $current_url['path'] ?? '', $wpforms_route ) === 0;
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
/**
[275] Fix | Delete
* Determine if the request is WPForms AJAX.
[276] Fix | Delete
*
[277] Fix | Delete
* @since 1.8.0
[278] Fix | Delete
*
[279] Fix | Delete
* @return bool
[280] Fix | Delete
*/
[281] Fix | Delete
function wpforms_is_ajax(): bool {
[282] Fix | Delete
[283] Fix | Delete
if ( ! wp_doing_ajax() ) {
[284] Fix | Delete
return false;
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
// Make sure the request target is admin-ajax.php.
[288] Fix | Delete
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[289] Fix | Delete
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && basename( sanitize_text_field( wp_normalize_path( $_SERVER['SCRIPT_FILENAME'] ) ) ) !== 'admin-ajax.php' ) {
[290] Fix | Delete
return false;
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[294] Fix | Delete
$action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : '';
[295] Fix | Delete
[296] Fix | Delete
return strpos( $action, 'wpforms_' ) === 0;
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
/**
[300] Fix | Delete
* Determine if request is frontend AJAX.
[301] Fix | Delete
*
[302] Fix | Delete
* @since 1.5.8.2
[303] Fix | Delete
* @since 1.6.5 Added filterable frontend ajax actions list as a fallback to missing referer cases.
[304] Fix | Delete
* @since 1.6.7.1 Removed a requirement for an AJAX action to be a WPForms action if referer is not missing.
[305] Fix | Delete
* @since 1.8.0 Added clear separation between frontend and admin AJAX requests, see `wpforms_is_admin_ajax()`.
[306] Fix | Delete
*
[307] Fix | Delete
* @return bool
[308] Fix | Delete
*/
[309] Fix | Delete
function wpforms_is_frontend_ajax(): bool {
[310] Fix | Delete
[311] Fix | Delete
if ( wpforms_is_ajax() && ! wpforms_is_admin_ajax() ) {
[312] Fix | Delete
return true;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
// Try detecting a frontend AJAX call indirectly by comparing the current action
[316] Fix | Delete
// with a known frontend actions list in case there's no HTTP referer.
[317] Fix | Delete
[318] Fix | Delete
$ref = wp_get_raw_referer();
[319] Fix | Delete
[320] Fix | Delete
if ( $ref ) {
[321] Fix | Delete
return false;
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
$frontend_actions = [
[325] Fix | Delete
'wpforms_submit',
[326] Fix | Delete
'wpforms_file_upload_speed_test',
[327] Fix | Delete
'wpforms_upload_chunk_init',
[328] Fix | Delete
'wpforms_upload_chunk',
[329] Fix | Delete
'wpforms_file_chunks_uploaded',
[330] Fix | Delete
'wpforms_remove_file',
[331] Fix | Delete
'wpforms_restricted_email',
[332] Fix | Delete
'wpforms_form_locker_unique_answer',
[333] Fix | Delete
'wpforms_form_abandonment',
[334] Fix | Delete
];
[335] Fix | Delete
[336] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[337] Fix | Delete
$action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : '';
[338] Fix | Delete
[339] Fix | Delete
/**
[340] Fix | Delete
* Allow modifying the list of frontend AJAX actions.
[341] Fix | Delete
*
[342] Fix | Delete
* This filter may be running as early as `plugins_loaded` hook.
[343] Fix | Delete
* Please mind the hook order when using it.
[344] Fix | Delete
*
[345] Fix | Delete
* @since 1.6.5
[346] Fix | Delete
*
[347] Fix | Delete
* @param array $frontend_actions A list of frontend actions.
[348] Fix | Delete
*/
[349] Fix | Delete
$frontend_actions = (array) apply_filters( 'wpforms_is_frontend_ajax_frontend_actions', $frontend_actions );
[350] Fix | Delete
[351] Fix | Delete
return in_array( $action, $frontend_actions, true );
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
/**
[355] Fix | Delete
* Determine if request is admin AJAX.
[356] Fix | Delete
*
[357] Fix | Delete
* @since 1.8.0
[358] Fix | Delete
*
[359] Fix | Delete
* @return bool
[360] Fix | Delete
*/
[361] Fix | Delete
function wpforms_is_admin_ajax(): bool {
[362] Fix | Delete
[363] Fix | Delete
if ( ! wpforms_is_ajax() ) {
[364] Fix | Delete
return false;
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
$ref = wp_get_raw_referer();
[368] Fix | Delete
[369] Fix | Delete
if ( ! $ref ) {
[370] Fix | Delete
return false;
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
$path = wp_parse_url( $ref, PHP_URL_PATH );
[374] Fix | Delete
$admin_path = wp_parse_url( admin_url(), PHP_URL_PATH );
[375] Fix | Delete
[376] Fix | Delete
// Is an admin AJAX call if HTTP referer contain an admin path.
[377] Fix | Delete
return strpos( $path, $admin_path ) !== false;
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
/**
[381] Fix | Delete
* Check if Gutenberg is active.
[382] Fix | Delete
*
[383] Fix | Delete
* @since 1.6.2
[384] Fix | Delete
*
[385] Fix | Delete
* @return bool True if Gutenberg is active.
[386] Fix | Delete
* @noinspection PhpUndefinedFunctionInspection
[387] Fix | Delete
*/
[388] Fix | Delete
function wpforms_is_gutenberg_active(): bool {
[389] Fix | Delete
[390] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/plugin.php';
[391] Fix | Delete
[392] Fix | Delete
if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
[393] Fix | Delete
return in_array( get_option( 'classic-editor-replace' ), [ 'no-replace', 'block' ], true );
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
if ( is_plugin_active( 'disable-gutenberg/disable-gutenberg.php' ) ) {
[397] Fix | Delete
return ! disable_gutenberg();
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
return true;
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
/**
[404] Fix | Delete
* Determines whether the current request is a WP CLI request.
[405] Fix | Delete
*
[406] Fix | Delete
* @since 1.7.6
[407] Fix | Delete
*
[408] Fix | Delete
* @return bool
[409] Fix | Delete
*/
[410] Fix | Delete
function wpforms_doing_wp_cli(): bool {
[411] Fix | Delete
[412] Fix | Delete
return defined( 'WP_CLI' ) && WP_CLI;
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
/**
[416] Fix | Delete
* Determines whether search functionality is enabled for Choices.js elements in the admin area.
[417] Fix | Delete
*
[418] Fix | Delete
* @since 1.8.3
[419] Fix | Delete
*
[420] Fix | Delete
* @param array $data Data to be displayed in the dropdown.
[421] Fix | Delete
*
[422] Fix | Delete
* @return string
[423] Fix | Delete
*/
[424] Fix | Delete
function wpforms_choices_js_is_search_enabled( $data ): string {
[425] Fix | Delete
[426] Fix | Delete
/**
[427] Fix | Delete
* Filter max number of items at which no search box is displayed.
[428] Fix | Delete
*
[429] Fix | Delete
* @since 1.8.3
[430] Fix | Delete
*
[431] Fix | Delete
* @param int $count Max items count.
[432] Fix | Delete
*/
[433] Fix | Delete
return count( $data ) >= apply_filters( 'wpforms_choices_js_is_search_enabled_max_limit', 20 ) ? 'true' : 'false';
[434] Fix | Delete
}
[435] Fix | Delete
[436] Fix | Delete
/**
[437] Fix | Delete
* Check if a form is a template.
[438] Fix | Delete
*
[439] Fix | Delete
* @since 1.8.8
[440] Fix | Delete
*
[441] Fix | Delete
* @param int|WP_Post $form Form ID or object.
[442] Fix | Delete
*
[443] Fix | Delete
* @return bool True if the form is a template.
[444] Fix | Delete
*/
[445] Fix | Delete
function wpforms_is_form_template( $form ): bool {
[446] Fix | Delete
[447] Fix | Delete
$template_post_type = 'wpforms-template';
[448] Fix | Delete
[449] Fix | Delete
if ( $form instanceof WP_Post ) {
[450] Fix | Delete
return $form->post_type === $template_post_type;
[451] Fix | Delete
}
[452] Fix | Delete
[453] Fix | Delete
return $template_post_type === get_post_type( $form );
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
/**
[457] Fix | Delete
* Checks if the current screen is using the block editor.
[458] Fix | Delete
*
[459] Fix | Delete
* @since 1.8.8
[460] Fix | Delete
*
[461] Fix | Delete
* @return bool True if the current screen is using the block editor, false otherwise.
[462] Fix | Delete
*/
[463] Fix | Delete
function wpforms_is_block_editor(): bool {
[464] Fix | Delete
[465] Fix | Delete
$screen = get_current_screen();
[466] Fix | Delete
[467] Fix | Delete
return $screen && method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor();
[468] Fix | Delete
}
[469] Fix | Delete
[470] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function