3

I have a Wordpress plugin that is no longer maintained but I have not found any plugin that satisfactorily replaces it. As a result, updates to PHP are starting to generate warnings in the plugin. I have little PHP knowledge and am not sure what, exactly, I need to do to update the following snippet so as to avoid the warning "Declaration of case-insensitive constants is deprecated" under PHP 7.3.

Here is the snippet:

$uploads = wp_upload_dir();

define( 'DOIFD_SERVICE', '', true );
define( 'DOIFD_VERSION', '2.1.6' );
define( 'DOIFD_URL', plugin_dir_url( __FILE__ ) );
define( 'DOIFD_DIR', plugin_dir_path( __FILE__ ) );
define( 'DOIFD_DOWNLOAD_DIR', $uploads[ 'basedir' ] . '/doifd_downloads/' );
define( 'DOIFD_DOWNLOAD_URL', $uploads[ 'baseurl' ] . '/doifd_downloads/' );
define( 'DOIFD_IMG_URL', plugin_dir_url( __FILE__ ) . 'public/assets/img/' );
define( 'DOIFD_ADMIN_IMG_URL', plugin_dir_url( __FILE__ ) . 'admin/assets/img/' );
2
  • 2
    php.net/define mentions "Defining case-insensitive constants is deprecated as of PHP 7.3.0.", so remove third parameter of your first define call (and make sure it's always used with uppercase letters).
    – Jeto
    Commented Dec 6, 2019 at 10:01
  • What have you tried so far? Where are you stuck?
    – Nico Haase
    Commented Sep 27, 2023 at 6:59

3 Answers 3

10

The case_insensitive parameter is no longer supported, so you should remove the third argument (true) from the function call.

In your case, the important part is that you need to check the code to see if DOIFD_SERVICE is used in places where it's not all caps, for example doifd_service, and replace all the instances with all caps DOIFD_SERVICE (there are probably some in the code, or else the parameter would probably not have been set to true)

In other words, replace this:

define( 'DOIFD_SERVICE', '', true );

With this:

define( 'DOIFD_SERVICE', '' );
3

You have to change

define( 'DOIFD_SERVICE', '', true );
                           ^^^^^^^

to

define( 'DOIFD_SERVICE', '');

An issue can be, that doifd_service and doIFd_Service and ... are not longer defined. If this is important, add

 define( 'doifd_service', '');

Mixed cases (CamelCase) are not usual in combination with underscore.

0

code is different i use "SaFly-Curl-Patch" third party plugin for solving php error there is same error so to fix it, goto plugin folder find edit safly plugin,

define('SCP_INC', 'safly', TRUE);

To

define('SCP_INC', 'safly');

probably on line no 26, hope this work for you!

Not the answer you're looking for? Browse other questions tagged or ask your own question.