Create_function deprecated

60 views Asked by At

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 );

// END ENQUEUE PARENT ACTION

I hope some kind hearted person will repair this error for me and enable the website to run correctly again, until such time as the current total redesign is completed.

Many Thanks

Iain Morrison

Due to not having PHP knowledge I decided it was better not to try anything as I would probably break it completely!

1

There are 1 answers

1
Jarmo T On

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

For example:

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

Please note that Stack Overflow is not a place to find free software development services. You should try to solve the issue yourself first.