• Hello,

    i’ve just activated code snippet on my website and it appears it broke it.
    I had to go in recovery mode and delete the plugin.

    This is the message from WP dashboard once in recovery mode:
    This plugin failed to load properly and is paused during recovery mode.

    An error of type E_ERROR was caused in line 1 of the file /home/tastycom/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(361) : eval()’d code. Error message: Uncaught Error: Call to undefined function genesis_register_sidebar() in /home/tastycom/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(361) : eval()’d code:1 Stack trace: #0 /home/tastycom/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(361): eval() #1 /home/tastycom/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(450): execute_snippet(‘genesis_registe…’, 7) #2 /home/tastycom/public_html/wp-includes/class-wp-hook.php(286): execute_active_snippets(”) #3 /home/tastycom/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #4 /home/tastycom/public_html/wp-includes/plugin.php(465): WP_Hook->do_action(Array) #5 /home/tastycom/public_html/wp-settings.php(394): do_action(‘plugins_loaded’) #6 /home/tastycom/public_html/wp-config.php(85): require_once(‘/home/tastycom/…’) #7 /home/tastycom/public_html/wp-load.php(37): require_once(‘/home/tastycom/…’) #8 /home/tastycom/public_html/wp-login.php(12): require(‘/home/tastycom/…’) #9 {

    Are you investigating the problem?

    Best regards,
    Giulio

Viewing 2 replies - 1 through 2 (of 2 total)
  • Code Snippet has big problem concerning, if function exists or not. Code Snippet can’t reliable check:

    1. If the function is available in the situation, where it has been called. This issue can crash site. There is two sub-problems:
    1. You have defined your own function, but it is not in the calling situation available. If you have defined your own function, which you have in another snippet, set for the snippet, which has the called function, lower priority.
    2. If the function is defined by some plugin but in the situation the function has been called, the function is not available. Changing priorities doesn’t help in this connection.
    • It doesn’t always find defined function in another snippet. This doesn’t crash site, but prevents saving the snippet. This can sometimes solve by using if and function_exists() function.
    • It allows to save snippet even if the function has been already defined in another snippet. This crash the site.
    • So if you use function defined by yourself or defined by some plugin, you can’t rely on that the code doesn’t crash you site. You must carefully yourself think, which function is available in which situation. Unfortunately Code Snippet works in this respect quite unreliable.

    Plugin Author ImageShea Bunge

    (@bungeshea)

    Hi @giuliovallata,

    The problem appears to be stemming from the fact that you are trying to use Genesis functions before they have been defined. As Genesis is a theme, and not a plugin, it will not be fully loaded by the time that snippets are executed.

    Instead, you should use a filter or action hook to ensure that you execute your Genesis code after the theme has fully loaded its functions and hooks.

    It’s a little difficult to give specific advice for how to fix the snippet in question without knowing its code, but if you are willing to post the code here for me to look at, I can fix it up for you so that it can safely be used as a snippet.

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

The topic ‘Code Snippet has broke my website’ is closed to new replies.