• Resolved tepelstreel

    (@tepelstreel)


    Hello and thanks for this wonderful plugin!

    With update to WP 4.5 I get the message in my debug log that ‘add_object_page’ is deprecated and you should use ‘add_menu_page’ instead.

    In index.php at line 69 – 72 you have the following code snippet:

    if (!function_exists("add_object_page") || $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["menu_group"])
    		$my_admin_page = add_menu_page($pageTitle, $pluginTitle, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], $base_page, $base_function, $GOTMLS_Full_plugin_logo_URL);
    	else
    		$my_admin_page = add_object_page($pageTitle, $pluginTitle, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], $base_page, $base_function, $GOTMLS_Full_plugin_logo_URL);

    wich could be changed to:

    if (function_exists("add_menu_page") || $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["menu_group"])
    		$my_admin_page = add_menu_page($pageTitle, $pluginTitle, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], $base_page, $base_function, $GOTMLS_Full_plugin_logo_URL);
    	else
    		$my_admin_page = add_object_page($pageTitle, $pluginTitle, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], $base_page, $base_function, $GOTMLS_Full_plugin_logo_URL);

    in order to avoid the entry in the debug log. Would that be an option for future updates?

    Cheers,
    Stefan

    https://wordpress.org/plugins/gotmls/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Eli

    (@scheeeli)

    Thanks for reporting this error. I have been trying to recreate this problem but I don’t get that error to come up on my sites that have 4.5

    I also don’t how the change you suggested would help…
    Current logic:
    if function add_object_page does NOT exist then use add_menu_page
    else use function add_object_page

    Your new logic:
    if function add_menu_page DOES exist then use add_menu_page
    else use function add_object_page

    I guess that worked for you because add_menu_page DOES exist so it never uses add_object_page, which is really what I should change here, I need to completely remove add_object_page as an option so that nobody gets that error that you got.

    I will work that in to my next update and release that fix very soon.

    Thread Starter tepelstreel

    (@tepelstreel)

    It seems to be all about backwards compability. I come with that special site where it occured from WP 2.6 or somewhere. My guess is that the function still exists in some older core files. But the new function exists as well.

    I don’t really get the thing either why you couldn’t repoduce the behaviour. Being a plugin author myself, on the other hand I have enough of those cases myself. Someone has an error that I never am able to get. 🙂

    Just change line 69 to
    $my_admin_page = add_menu_page($pageTitle, $pluginTitle, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["user_can"], $base_page, $base_function, $GOTMLS_Full_plugin_logo_URL);
    would help of course as well, but you would loose backwards compability.

    But thanks very much for your quick answer and for considering the change.

    Plugin Author Eli

    (@scheeeli)

    I just released a new plugin update that fixes this issue. Please upgrade to version 4.16.17 and let me know if that works for you.

    Thread Starter tepelstreel

    (@tepelstreel)

    Hi there,

    sorry for a late answer. I was a bit busy the past days. But I did the update and everything seems to fine now.

    Thanks a lot for reacting that fast!

    Best,
    Stefan

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Using deprecated function add_object_page’ is closed to new replies.