Call to undefined function add_action() (3 posts)

  1. Frank Goossens
    Posted 6 years ago #

    (repost from plugins-forum)
    I'm the author of a plugin (wp-youtube-lyte) which seems to work on the majority of installations.

    There are however a few instances where a "Call to undefined function add_action() in options.php on line 2" is generated. Indeed, options.php opens with;

    add_action('admin_menu', 'lyte_create_menu');
    function lyte_create_menu() {

    Is there anything wrong with the code? Is there any way to work around this error? Or is this due to (mis-)configuration of the blog instance and so entirely out of my hands?

  2. Mark / t31os

    Posted 6 years ago #

    That's usually what happens when the file is queried directly, and not loaded via WordPress, ie..

    The page was requested like this..


    and not..


    Depending on what your plugin page URL looks like, it may differ to the two above, but should illustrate the point nonetheless.

    Simple if( !function_exists( 'some_wordpress_function' ) ) die('Direct request message to show.'); should fix that for you ..

  3. Frank Goossens
    Posted 6 years ago #

    thanks mark, i understand now. guess putting an empty index.html in place will prevent google & others to see directory contents (for those instances where webservers are not configured to disallow directory listing), so they won't try to index the standalone options.php any more.

Topic Closed

This topic has been closed to new replies.

About this Topic