WordPress.org

Forums

[resolved] deregister script "Trying to get property of non-object in..." notice (6 posts)

  1. Tijhaart
    Member
    Posted 3 years ago #

    I want to deregister a script on certain pages, but I get php notices when I call wp_deregister_script during the "wp_print_scripts" action.

    The notices occur in "wp-includes/class.wp-scripts.php on line 158". The first: "Undefined index: <scriptname>" and second: "Trying to get property of non-object".

  2. keesiemeijer
    moderator
    Posted 3 years ago #

    Try it with the wp_enqueue_scripts action hook.

  3. Tijhaart
    Member
    Posted 3 years ago #

    I will give it a try. Thanks.

  4. manuelmasia
    Member
    Posted 3 years ago #

    Some result... I already tried for you :-)

  5. manuelmasia
    Member
    Posted 3 years ago #

    Ah... sorry, it depends on the fact that somewhere the script is enqueued, so you must use wp_dequeue_script.

  6. Tijhaart
    Member
    Posted 3 years ago #

    wp_dequeue_script was actually the problem, because when I hooked into this action, the script didn't get removed. With wp_print_scripts it did got removed but would result in the above notice.

    In the end is doesn't matter, because the script I wanted to remove was enabled by a plugin and I'm not going to use the plugin anymore.

Topic Closed

This topic has been closed to new replies.

About this Topic