• Hi, first off I love your plugin ( should be part of the wordpress core functionality ).

    I am a fairly experienced PHP developer and use this plugin on a site that uses a highly customized backed, but still includes the wp_head() and wp_footer() to theme the site, and provide some basic WordPress support, such as the menu and hence this plugin.

    Normally this would probably not cause as big an issue but because we also use OptimizePress on the front end I am not able to add code to the functions.php file ( because when they do updates it gets replaced ).

    That situation leaves me with some custom functions that are used by this plugin that I cannot easily add to the front end ( short of creating a separate plugin for them ).

    So now to the root of the problem, the eval() call that processes custom functions currently does not check that those functions actually exist before calling them, granted in some cases it would be better to allow the error to happen, so it’s visible to the site owner. So it might be better to do this as an option or something like having a debugging mode that could be turned on and off .. etc.

    I leave that to your discretion, but thought I would mention the issue and a possible fix for it.

    on line 97 of init.php change

    eval( ‘$visible = ‘ . $logic . ‘;’ );

    to

    $function = preg_replace(‘/\(.*\)$/’, ”, $logic);
    if(function_exists($function)){
    eval( ‘$visible = ‘ . $logic . ‘;’ );
    }

    The regx just strips out the arguments ( so function exists will work properly ).

    Thanks,

    Thanks,

    https://www.ads-software.com/plugins/menu-items-visibility-control/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author shazdeh

    (@shazdeh)

    I’m not so sure about this approach, one problem is in the Logic field you can use any PHP code and not just WP conditional tags, so I wonder how the regex would work if used with complex logics.
    Better solution I think would be to include the function_exists call inside the Logic field itself, for example:

    function_exists( 'is_woocommerce' ) && is_woocommerce()

    Thread Starter artisticphoenix

    (@artisticphoenix)

    That makes sense, anyway I have updated my code as a plugin to wordpress so that the function I need is always there, It was a pretty edge case type case anyway I just wanted to let you know there were no checks for the eval code that called the menu codes.

    Really what we have is a completely separate backend, and WordPress is just for the front end and a bit of content in a few backend pages and the menues, the rest of the site is done with a combination of CodeIgniter and a third party membership application. What I have done is include the functionality as a plugin to WordPress, because my employer also wants to use OptimizePress for the wordpress, which prevents me from just adding it into the functions.php of the theme.

    So like I said its a very edge case setup. But I absolutely love the plugin, and I’ve even suggested as a answer to a few questions on Stack Overflow.

    Keep up the good work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Request code change / update to fix – Fatal error: Call to undefined function’ is closed to new replies.