Debug & fix deprecated “create_function” WordPress

WordPress changes its functions and version with new functionality time to time  and each WordPress version have some dependencies even WordPress change log added what functions are added and functions that are deprecated after the current version.

So when your WordPress version auto updated then it can throw many PHP warning related to WordPress dependencies and deprecated functions.

In this topic we will cover how to check WordPress throw any kind of warning or errors and we will help you to debug the issue and then fix the bug.

To debug the WordPress you should have knowledge of PHP

There are some basic steps that can help you to find the errors and deprecated warnings:

  1. Access your website code using FTP
  2. Open your wp-config.php in text editor

1)  Access your website code using FTP:


FTP is a File transfer protocol that help you to perform actions on server with files and folders. so you can get this  details from your cPanel and when you have all details  then download Filezilla client  software or tool and using FileZilla you can access your website using FTP details.
When you successfully connected FileZilla tool  to server then let’s move to next steps.

2) Open your wp-config.php in text editor :

Now after FileZilla connected . you can see right side panel is for server so in your root directory of server you should find wp-config.php file and open it in your text editor then find these line
DIFINE('WP_DEBUG',FALSE)

Now replace “FALSE” to “TRUE” and save file and upload this file again .
Now open your browser you can see if website have any errors then it will print all the warning and errors in your website .
Okay if your website have deprecated “create_function”  error then wp debug help you to find the file where this error exist.

So you need to open that file if warning clearly display the file name and code line number then just open that file and replace create_function parameter from named function or anonymous function to explain let me add some code here .

add_action('HOOK_NAME',create_function( 'parameter1', 'parameter2'), 1 );
So this part of create_function( 'parameter1', 'parameter2') will replace with add_action ( 'HOOK_NAME', 'run_my_code' )

/*run_my_code is named function you can choose name whatever you need */
add_action ( 'HOOK_NAME', 'run_my_code' );


function run_my_code() {
/* Add your logic here*/
}

This is the way to debug and fix the deprecated function error .
Hope it will help you to understand how to make it working when you find this error.
If you need my help, just contact me here .

Leave a Comment

Related Blog

Sign up for our newsletter to stay up to
date with tech news!