• Resolved Lea

    (@leac)


    Hi,

    Whan I save a nav-menu (on wp-admin/nav-menus.php), I get error messages:

    Notice: Undefined variable: youtube_details in /wp-content/plugins/automatic-featured-images-from-videos/automatic-featured-images-from-videos.php on line 137

    Notice: Undefined variable: vimeo_details in /wp-content/plugins/automatic-featured-images-from-videos/automatic-featured-images-from-videos.php on line 137

    These error messages are repeated for every item in the menu.

    The source of the error

    It seems that the code is trying to use the $youtube_details and $vimeo_detail variables, but those aren’t defined since their definition occurs inside conditions that aren’t met:
    if ( $youtube_id )
    and
    if ( $vimeo_id )

    Suggested Solution

    I’m actually surprised that this function, wds_check_if_content_contains_video, would run at all in the admin page of the nav-menus. But if it does have to run, then maybe a check for isset of those variable would be in place.

    Such that line 137 would have the following code:

    && ( (isset($youtube_details) && $youtube_details) || ( $vimeo_details) )

    Thanks

    • This topic was modified 3 years, 9 months ago by Lea.
    • This topic was modified 3 years, 9 months ago by Lea.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    My hunches are more that menu items are posts in their own rights, thus our running on the save_post hook is ending up applying here. Should be amended if that’s indeed the case.

    Regarding getting rid of the notices as a whole, without waiting for us, you can add the following around line 119-120, right below the video_thumbnail_url empty string declaration:

    $youtube_details     = '';
    $vimeo_details       = '';
    

    This should get rid of those from showing up for the time being.

    Thread Starter Lea

    (@leac)

    Thank you for the explanation and the workaround!

    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘When saving a nav-menu I get error messages about undefined variables in plugin’ is closed to new replies.