Forum Moderators: coopster

Message Too Old, No Replies

PHP Warning: Use of undefined constant ultra hidey install

old coding needs to be fixed.

         

tyankee

10:32 pm on Aug 4, 2021 (gmt 0)

10+ Year Member



Getting the following error message:

[04-Aug-2021 22:18:39 UTC] PHP Warning: Use of undefined constant ultra_hidey_install - assumed 'ultra_hidey_install' (this will throw an Error in a future version of PHP) in /home/g8x/public_html/kssc.org/wp-content/plugins/ultra-hide-comments-box/ultra-hide-comment-box.php on line 31
[04-Aug-2021 22:18:39 UTC] PHP Warning: Use of undefined constant ultra_

Here is the coding and some coding around it:
/* Ultra Hide CONSTANTS */
if (!defined('ULTRA_HIDEY_VERSION')) {
define("ULTRA_HIDEY_VERSION", "1.1.4");
}

if (!defined('ULTRA_HIDEY_DIR')) {
define('ULTRA_HIDEY_DIR', WP_PLUGIN_DIR . '/' . "ultra-hide-comments-box/");
}

/* During plugin installation store ultra hide plugin version + add option for storing categories list */
if (!function_exists(ultra_hidey_install)) {
function ultra_hidey_install() {
/* Store Ultra Hide Comment Box Version */
add_option("ultra_hidey_version", "ULTRA_HIDEY_VERSION");
add_option("ultra_hidey_catlist", "");
}
}


Line 31 where the error happens is:
if (!function_exists(ultra_hidey_install)) {

Dimitri

10:48 pm on Aug 4, 2021 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Constants are case-sensitive.

w3dk

12:08 am on Aug 5, 2021 (gmt 0)

10+ Year Member Top Contributors Of The Month




if (!function_exists(ultra_hidey_install)) {


You shouldn't be using a "constant" here in the first place (which is why it's "undefined"). You are missing quotes around the literal string 'ultra_hidey_install'. In other words:


if (!function_exists('ultra_hidey_install')) {


It would have "worked" in earlier versions of PHP (although it would have still generated an E_NOTICE) because the undefined constant would have defaulted to a string of the same name, ie. 'ultra_hidey_install'

Conversely, the following looks wrong:


add_option("ultra_hidey_version", "ULTRA_HIDEY_VERSION");


You should presumably be passing the constant ULTRA_HIDEY_VERSION (ie. the value "1.1.4") as the 2nd argument to the above function call, not the literal string "ULTRA_HIDEY_VERSION". (?)

tyankee

2:52 am on Aug 5, 2021 (gmt 0)

10+ Year Member



thank you @w3dk. i think that worked.