From 1b5120ed16c6c7a570b59cba023742a5bc01d4ad Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Mon, 13 May 2024 12:48:38 -0300 Subject: [PATCH 1/2] Add a null check to avoid deprecated message when previewing --- classes/controllers/FrmFormsController.php | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index 34880e501e..798216fe42 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -596,9 +596,36 @@ private static function load_direct_preview() { $form = FrmForm::getAll( array(), '', 1 ); } + self::fix_deprecated_null_param_warning(); + require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php'; } + /** + * Some themes have a null $src value. + * This function adds a filter to ensure that $src is not null. + * WP will call str_starts_with with the null value triggering a deprecated message otherwise. + * + * @since x.x + * + * @return void + */ + private static function fix_deprecated_null_param_warning() { + add_filter( + 'script_loader_src', + /** + * @param string|null $src + * @return string + */ + function( $src ) { + if ( is_null( $src ) ) { + $src = ''; + } + return $src; + } + ); + } + public static function untrash() { self::change_form_status( 'untrash' ); } From 4a00ed19b098005f924a1977f93302b62319ec4f Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Mon, 13 May 2024 12:53:36 -0300 Subject: [PATCH 2/2] Add a space (phpcs) --- classes/controllers/FrmFormsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index 798216fe42..b94f69b15b 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -617,7 +617,7 @@ private static function fix_deprecated_null_param_warning() { * @param string|null $src * @return string */ - function( $src ) { + function ( $src ) { if ( is_null( $src ) ) { $src = ''; }