• Resolved wp_kc

    (@wp_kc)


    I was installing your most excellent plug-in on a web site yesterday and found these entries in the debug log…

    [11-Jul-2018 16:47:30 UTC] PHP Deprecated:  Function create_function() is deprecated in /wp-content/plugins/juiz-social-post-sharer/admin/jsps-admin.inc.php on line 192
    [11-Jul-2018 16:47:30 UTC] PHP Deprecated:  Function create_function() is deprecated in /wp-content/plugins/juiz-social-post-sharer/admin/jsps-admin.inc.php on line 195
    [11-Jul-2018 16:47:30 UTC] PHP Deprecated:  Function create_function() is deprecated in /wp-content/plugins/juiz-social-post-sharer/admin/jsps-admin.inc.php on line 201
    [11-Jul-2018 16:47:30 UTC] PHP Deprecated:  Function create_function() is deprecated in /wp-content/plugins/juiz-social-post-sharer/admin/jsps-admin.inc.php on line 211

    I looked at those line numbers and saw code like this…
    add_settings_field( 'juiz_sps_temp_submit', get_submit_button( __( 'Save Changes' ), 'secondary' ), create_function( '', 'return "";' ), JUIZ_SPS_SLUG, 'juiz_sps_plugin_main' );

    The web site is running on PHP7.2, and the php.net documentation does say this function is depreciated.

    To future proof these lines of code, you should probably replace create_function( ”, ‘return “”;’ ) with the WordPress defined function __return_empty_string(). So the example line of code above would become…

    add_settings_field( 'juiz_sps_temp_submit', get_submit_button( __( 'Save Changes' ), 'secondary' ), '__return_empty_string', JUIZ_SPS_SLUG, 'juiz_sps_plugin_main' );

    Thanks again for your work on this great plugin.

  • The topic ‘PHP Deprecated: Function create_function()’ is closed to new replies.