admin管理员组

文章数量:1322181

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Our WP Debug is report that 'Function create_function() is deprecated'. Any idea how to rewrite this code to not include create_function ?

 self::register_form_init_scripts( $form, $field_values, $ajax );

            if ( apply_filters( 'gform_init_scripts_footer', false ) ) {
                add_action( 'wp_footer', create_function( '', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');' ), 20 );
                add_action( 'gform_preview_footer', create_function( '', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');' ) );
            }
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Our WP Debug is report that 'Function create_function() is deprecated'. Any idea how to rewrite this code to not include create_function ?

 self::register_form_init_scripts( $form, $field_values, $ajax );

            if ( apply_filters( 'gform_init_scripts_footer', false ) ) {
                add_action( 'wp_footer', create_function( '', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');' ), 20 );
                add_action( 'gform_preview_footer', create_function( '', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');' ) );
            }
Share Improve this question asked Sep 17, 2020 at 16:43 user3217495user3217495 1032 bronze badges 1
  • why not just use a anonymous function and call GFFormDisplay::footer_init there? what is the minimum php version you require? – Sisir Commented Sep 17, 2020 at 17:35
Add a comment  | 

1 Answer 1

Reset to default 2

You no longer need to use create_function you can instead just use an anonymous function:

add_action( 'gform_preview_footer', create_function( '', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');' ) );

Should be:

add_action( 'gform_preview_footer', function() use ($form){
    GFFormDisplay::footer_init_scripts($form['id']);
});

https://www.php/manual/en/functions.anonymous.php

本文标签: phpError39createfunction is deprecated39