Subscribe to RSS feed Subscriure's al feed RSS or o follow me em segueixen on Twitter? a Twitter?
Haven't you come across some meaningless pile of text, after which nothing is displayed? No has trobat amb algun munt de sentit del text, després d'això es visualitza res? It breaks down the whole theme, causing problems for visitors and search bots alike. Es desglossa el tema sencer, causant problemes per als visitants i els robots de cerca per igual.

Don't we all hate those error codes? No tots odiem els codis d'error?
What are function calls? Què són les crides a funció?
Function calls are bits of PHP code that looks like this: <?php ns_show_top_commentators(); ?> Les crides a funcions són trossos de codi PHP que són aquestes: <?php ns_show_top_commentators(); ?>
Most plugins have such tags for specific uses; the above-mentioned code is to list the top commentators using the Show Top Commentators plugin. La majoria d'aquests plugins tenen etiquetes per a usos específics, el codi esmentat dalt és a la llista dels comentaristes utilitzen la Top comentaristes Mostra plugin.
The reason La raó
PHP function calls are notorious for breaking the theme, if the requested function does not exist. Les crides a funcions PHP són coneguts per trencar el tema, si la funció demanada no existeix. This usually happens when you add a function call for a plugin that you have disabled. Això passa generalment quan s'afegeix una crida a la funció d'un plugin que té discapacitat. The result will be unaccessible blogs, which are caused by the behaviour of broken function calls. El resultat serà inaccessible blocs, que són causats pel comportament de les crides a funcions trencat. WordPress cuts off the rendering of page when it stumbles over a broken function all. WordPress talls fora de la prestació de la pàgina quan es ensopega amb una funció trencat tots. Thus, depending on where you placed the broken code(sidebar/header/footer), your content may not be displayed, sidebars hidden or footers gone awry. Així, depenent d'on es col loca el codi de partit (barra lateral / capçalera / peu de pàgina), el seu contingut no pot ser mostrada, barres laterals ocults o peus de pàgina anat malament.
The solution La solució
This problem can be overcome by using an if function_exists check. Aquest problema es pot superar mitjançant un xec, if function_exists What does it do? Què fer? It checks whether the given function actually exists, and if it does, proceeds to call the function. Es comprova si la funció donada en realitat existeix, i si ho fa, procedeix a trucar a la funció. This way, your theme will work even when the function call is broken. D'aquesta manera, el tema funcionarà fins i tot quan es trenca la crida de funció.
Let us see an example of the conditional code (for Alex King's Twitter Tools plugin, used here on the top navbar). Vegem un exemple del codi condicional (per Alex King's Twitter plugin de Eines, utilitzat aquí a la barra de navegació superior).
The normal code for the Twitter tools is this: El codi normal per les eines de Twitter és la següent:
<?php aktt_latest_tweet (); ?>
The conditional code would be this: El codi condicional seria la següent:
<?php if(function_exists(' aktt_latest_tweet ')) { aktt_latest_tweet (); } ?> <? Php if (function_exists ( 'aktt_latest_tweet')) (aktt_latest_tweet ();)?>
To use it for any other plugin, find and copy the what you find in place of aktt_latest_tweet in the first code block. Per a utilitzar-lo per qualsevol altre plugin, trobar i copiar la el que troba en el lloc de aktt_latest_tweet en el primer bloc de codi. Then, paste that part in places of the code in red in the second code block. A continuació, enganxa la part en els llocs del codi en vermell en el segon bloc de codi.
This is a bit tricky, but play with it in a Això és una mica complicat, però jugar amb ell en un test blog installed locally on your PC prova de bloc instal lat localment en el seu PC , and once you get it right, upload it to your server. , I una vegada que surti bé, pujar-lo al teu servidor. Feel free to leave a comment on any issues that crop up on the way. Siéntase lliure de deixar un comentari sobre les qüestions que sorgeixen en el camí.
Related reading Lectura relacionada
- Plugin Week promises a daily WordPress plugin for a week Plugin de setmana promet un plugin de WordPress al dia durant una setmana
- Follow CNNBrk on Twitter for breaking news updates Siga CNNBrk a Twitter per a actualitzacions de les notícies d'última hora
- How to get Vista theme for Firefox in Windows XP Com arribar-hi tema de Vista del Firefox en Windows XP
- Brighten up Firefox with Camifox theme Plena de color Firefox amb Camifox tema d'
Hi Sumesh, Hola Sumesh,
Interesting post. Interessant post. I really love tech related stuff, as I can always learn more. M'encanta coses relacionades amb la tecnologia, com sempre pot aprendre més. PHP is one of my weak points as I never learned coding. PHP és un dels meus punts febles, com mai vaig saber de codificació. Only trial by doing kind of stuff and reading about solutions like this is fascinating for me. Només judici per fer tipus de coses i de la lectura sobre les solucions d'aquest tipus és fascinant per a mi.
Good luck with your entry.:-) Bona sort amb la teva entrada. :-)
Monika Monika
@Monika: Thanks. @ Monika: Gràcies. As regards PHP, neither did I – its just a matter of interest, time and Pel que fa a PHP, jo tampoc, - la seva només una qüestió d'interès, el temps i
elbow grease greix del colzeeffort, plus some cheat sheets to learn PHP (hint: codex.wordpress.org) esforç, a més d'algunes fulles de trucs per aprendre PHP (pista: codex.wordpress.org)That's a great tip Sumesh. Aquesta és una Sumesh gran punta. It can be really easy not to notice these errors at the time and come back a few days later to find errors where you least expect them. Pot ser molt fàcil no adonar-se d'aquests errors en el temps i tornar uns dies després de trobar errors on menys t'ho esperes.
@Andrew: Thanks. @ Andrew: Gràcies. As a matter of fact, I hunted down this bug after I forgot to check my soccerblog.in, which had the error you see in screenshot above. Com a qüestió de fet, perseguits després d'aquest error se'm va oblidar revisar la meva soccerblog.in, que va tenir l'error que apareix en pantalla i de dalt.
Thanks.. Gràcies ..
as im not expert in php… com no sóc expert en PHP ...
so it helped me alot… and my problem is solved by reading ur post… thanks once again.. pel que em va ajudar molt ... i el meu problema és resolt mitjançant la lectura de post UR ... gràcies una vegada més ..