WordPress Template Modification Tips for Non-Programmers - Robustness WordPress modello di modificazione suggerimenti per i non programmatori - robustezza
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.
Filed under Elencato sotto CMS Software CMS Software , Headline News Headline News , How To Come , PHP , Pro Blogging Pro Blogging , Tech Note Nota tech , Web , Web Services Servizi Web , WordPress | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |





December 29th, 2005 at 1:37 am 29 dicembre 2005 a 1:37 am
[...] Thanks to Simple Thoughts for this simple way to keep things from breaking if and when I have to turn off a plugin in the future. [...] Grazie a pensieri semplici per questo semplice modo per mantenere le cose da rompere se e quando devo disattivare un plugin per il futuro. [...]
December 30th, 2005 at 12:40 pm 30 dicembre 2005 a 12:40 pm
[...] Despite all the warnings above if you still want to upgrade then please please please (repeatation intentional) backup the database and harden your templates against plugins before you upgrade. [...] Nonostante tutte le avvertenze di cui sopra, se desideri ancora aggiornare la invitiamo quindi ti invitiamo ti invitiamo a (repeatation intenzionale) di backup del database e indurire i modelli contro i collegamenti prima di eseguire l'aggiornamento. [...]
January 3rd, 2006 at 1:41 pm 3 gennaio 2006 a 1:41 pm
[...] Couple that with php’s “silent treatment” of errors. [...] Coppia che con php "silenzio di trattamento" di errori. In other words you and your viewers are greeted with a nice looking, white in color web page, whenever any (plugin) error occurs. In altre parole, voi ei vostri visitatori vengono accolti con un piacevole, in colore bianco pagina web, ogniqualvolta (plugin) di errore si verifica. Plugin errors could be as simple as having blank spaces at the end of plugin files after ?> to more complex ones like invalid argument to methods. Plug errori potrebbe essere più semplice avere spazi bianchi alla fine del plug file dopo?> Per quelli più complessi come argomento per non validi metodi. Update: Please check tips on making your plugins robust. Aggiornamento: Verifica suggerimenti su come rendere il vostro plugin robusto. [...]
September 5th, 2006 at 2:54 pm 5 settembre 2006 a 2:54 pm
[...] WordPress Template Modification Tips for Non-Programmers - Robustness -Simple Thoughts - Java and Web Technology Blog Hoe je wordpress-site bestand maken tegen crashende of niet geactiveerde plugins. [...] WordPress Template Modifica Suggerimenti per i non programmatori - Robustezza-pensieri semplici - Java e tecnologia Blog Hoe-je wordpress sito Bestand maken tegen crashende niet geactiveerde di collegamenti. Nu het nog overal inbouwen… (tags: howto PHP wordpress plugins) [...] Nu nog het inbouwen globale… (tag: howto PHP wordpress) [...]