Question:
How to Create_function deprecated in PHP?

Problem

I have taken over the 'admin' of a Wordpress website without the benefit of any documentation and it is falling over when creating invoices with this error. Whilst I can do somethings to get it going, I cannot fix broken PHP code and I am hoping that someone can fix this for me to get this working correctly again.


Deprecated: Function create_function() is deprecated in ../public_html/news/wp-content/themes/twentyseventeen-child/functions.php on line 12


The code in functions.php is shown below


<?php




add_filter( 'password_reset_expiration', function( $expiration ) {

    return MONTH_IN_SECONDS;

});


// Exit if accessed directly

if ( !defined( 'ABSPATH' ) ) exit;


add_action( 'woocommerce_single_product_summary', create_function( '', 'echo "<b><a href=\"https://009society.com/news/shop\">Continue Shopping</a></b>";' ), 35 );



// Increase the password expiration expiration to 5 days

add_filter('password_reset_expiration',function($expiration){return 5 * DAY_IN_SECONDS;});


// BEGIN ENQUEUE PARENT ACTION

// AUTO GENERATED - Do not modify or remove comment markers above or below:


if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):

    function chld_thm_cfg_locale_css( $uri ){

        if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )

            $uri = get_template_directory_uri() . '/rtl.css';

        return $uri;

    }

endif;

add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );


if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):

    function chld_thm_cfg_parent_css() {

        wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array(  ) );

    }

endif;

add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );

         

if ( !function_exists( 'child_theme_configurator_css' ) ):

    function child_theme_configurator_css() {

        wp_enqueue_style( 'chld_thm_cfg_separate', trailingslashit( get_stylesheet_directory_uri() ) . 'ctc-style.css', array( 'chld_thm_cfg_parent','twentyseventeen-style','twentyseventeen-block-style','twentyseventeen-colors-dark' ) );

    }

endif;

add_action( 'wp_enqueue_scripts', 'child_theme_configurator_css', 10 );


Solution:

Instead of creating functions through create_function you could just use an anonymous function.


add_action( 'woocommerce_single_product_summary', function(){

        echo "<b><a href=\"https://009society.com/news/shop\">Continue Shopping</a></b>";

    }, 35 );



Answered by: >Jarmo T

Credit: >StackOverflow


Blogs Link: 

>How to solve XGBoost model training fails in Python

>Python Error Solved: load_associated_files do not load a txt file

>How to build interactive_graphviz in Python

>How to solve encoding issue when writing to a text file, with Python?

>Python Error Solved: pg_config executable not found


Ritu Singh

Ritu Singh

Submit
0 Answers