Several WordPress plugins ask you to add certain code to the WordPress theme template files to make them work. Più di WordPress prego di aggiungere il codice per alcuni il tema WordPress file modello per farli funzionare. If you are not a PHP developer or you don’t have time to code review the plugin and you decide to activate the plugin then the plugin can very easily cause your site to crash or worse. Se non sei un sviluppatore di PHP o non avete tempo per la revisione del codice plug in e si decide di attivare il plugin allora il plugin può causare molto facilmente il tuo sito in crash o peggio. Often the errors are hard to detect (sporadic, happening only in certain conditions) and even harder to debug as you are not familiar with the code. Spesso gli errori sono difficili da individuare (sporadico, accadendo soltanto in determinate condizioni) e ancora più difficile di eseguire il debug di come lei non hanno familiarità con il codice. Today we will talk about a simple step you can take to make your site robust against untested and buggy plugins. Oggi parliamo di un semplice passo si può prendere per rendere il tuo sito robusta contro testate e buggy collegamenti.

Normally most of the time you are asked to include a code block similar to this: Normalmente la maggior parte del tempo viene chiesto di inserire un blocco di codice simile a questo:

The func_name obviously represents a function which the plugin author wants you to include; the arguments are as required for that function. La func_name ovviamente rappresenta una funzione che il plugin autore vuole che includono: gli argomenti sono come richiesto per tale funzione.

This can create two major issues. Questo può creare due grandi questioni.
Firstly if at any time you decide to disable the plugin then you will have to first remove the code from all your template files before you can safely de-activate / remove the plugin. In primo luogo, se in qualsiasi momento si decide di disattivare il plugin allora si dovrà prima rimuovere il codice da tutti i vostri file modello prima di poter sicurezza de-attivare / rimuovere il plug-in. Otherwise the pages in the site will fail to load properly. Altrimenti le pagine del sito non riuscirà a caricare correttamente.

Secondly the plugin itself may fail in certain conditions or always. In secondo luogo il plugin per sé potrebbe non riuscire a determinate condizioni o sempre. In the worst case you will find certain pages on your site fails to load sometimes. Nel peggiore dei casi troverete alcune pagine del tuo sito non riesce a caricarsi a volte. It could be long before you are aware of the problem. Si potrebbe a lungo prima di voi sono consapevoli del problema.

We will look at two small changes you can make to the code template above to take care of both of the problems described above. Vedremo due piccole modifiche che possono essere apportate al codice modello di sopra di prendersi cura di entrambi i problemi sopra descritti. First the modified code: In primo luogo il codice modificato:

if(function_exists(’ func_name ‘) @ func_name( arg1,arg2 …); ?> if (function_exists ( 'func_name') @ func_name (arg1, arg2…);?>
Remember to replace func_name with the actual name of the function. Ricordare di sostituire func_name con il nome effettivo della funzione.

Testing the existence of the function ensures that the code isn’t executed when the plugin is inactive / disabled. L'esistenza di test della funzione assicura che il codice non viene eseguito quando il plugin non è attivo / disattivato. This prevents the first problem. Ciò impedisce che il primo problema.

Appending an @ before the function name ensures that errors, if any, while executing the function are ignored and do not cause further problems down the road and do not prevent the overall page from displaying. Apporre la @ prima il nome della funzione assicura che gli errori, se del caso, mentre la funzione di esecuzione sono ignorati e non causare ulteriori problemi lungo la strada e non impediscono la pagina da visualizzare.

This fix works against all versions of WordPress and also in any other templating system which uses php code. Questa correzione funziona contro tutte le versioni di WordPress e anche in qualsiasi altro sistema di templating che utilizza il codice php.

Carefully make the changes following the template above to make your site more robust against WordPress plugins. Attentamente apportare le modifiche in base al modello di cui sopra per rendere il tuo sito più solido nei confronti di WordPress.