Subscribe to RSS feed Prihlásiť sa na odber RSS feed or alebo follow me za mnou on Twitter? on Twitter?
Haven't you come across some meaningless pile of text, after which nothing is displayed? Copak narazíte na nejaký zmysel, hromadu textu, po ktorom je zobrazená nič? It breaks down the whole theme, causing problems for visitors and search bots alike. Rozdeľuje sa celý motív, čo spôsobuje problémy pre návštevníkov a vyhľadávacie roboty podobne.

Don't we all hate those error codes? Nie sú všetci nenávidia tie poruchové kódy?
What are function calls? Čo sú volania funkcií?
Function calls are bits of PHP code that looks like this: <?php ns_show_top_commentators(); ?> Funkcie hovoru sú kúsky kódu PHP, ktorý vyzerá nasledovne: <?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. Väčšina pluginov má také značky pre špeciálne použitie vyššie uvedených-kód je na vrchole zoznamu komentátorov pomocou Zobraziť Top Komentátori plugin.
The reason Dôvodom
PHP function calls are notorious for breaking the theme, if the requested function does not exist. PHP funkcie hovory sú notoricky známy pre lámanie tému, ak požadované funkcie neexistuje. This usually happens when you add a function call for a plugin that you have disabled. To sa zvyčajne stáva, keď pridáte volanie funkcie pre plugin, ktorý ste zakázali. The result will be unaccessible blogs, which are caused by the behaviour of broken function calls. Výsledkom bude neprístupný blogy, ktoré sú spôsobené správaním rozbité volania funkcií. WordPress cuts off the rendering of page when it stumbles over a broken function all. WordPress odreže vykresľovania stránky, keď klopýtá cez rozbité všetky funkcie. Thus, depending on where you placed the broken code(sidebar/header/footer), your content may not be displayed, sidebars hidden or footers gone awry. V závislosti na tom, kde ste umiestnili zlomenej kód (sidebar / header / footer), môže obsah nedá zobraziť, postrehov skryté alebo päty preč nakrivo.
The solution Riešenie
This problem can be overcome by using an if function_exists check. Tento problém možno prekonať pomocou if function_exists skontrolovať. What does it do? Čo to robí? It checks whether the given function actually exists, and if it does, proceeds to call the function. Overuje, či je daná funkcia skutočne existuje, a ak áno, pokračuje volať funkciu. This way, your theme will work even when the function call is broken. Týmto spôsobom sa vaša tému práce aj pri volaní funkcie je rozbitá.
Let us see an example of the conditional code (for Alex King's Twitter Tools plugin, used here on the top navbar). Pozrime sa napríklad o podmienečné kód (Alex kráľa Twitter Tools plugin, tu použitý na hornej navigačnej lišty).
The normal code for the Twitter tools is this: Kód pre bežné nástroje Twitter je toto:
<?php aktt_latest_tweet (); ?>
The conditional code would be this: Dočasné kód by to byť:
<?php if(function_exists(' aktt_latest_tweet ')) { aktt_latest_tweet (); } ?> 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. Ak chcete použiť k inému pluginu, nájsť a skopírovať, čo nájdete v mieste aktt_latest_tweet v prvý blok kódu. Then, paste that part in places of the code in red in the second code block. Potom vložte časť v miestach kódu v červenom v druhom blok kódu.
This is a bit tricky, but play with it in a To je trochu zložité, ale hrať sa s nimi v test blog installed locally on your PC testovací blog nainštalovaný lokálne na vašom PC , and once you get it right, upload it to your server. , A akonáhle sa dostanete za správne, nahrať ich na server. Feel free to leave a comment on any issues that crop up on the way. Neváhajte a zanechať komentár ku všetkým otázkam, ktoré plodiny sa na ceste.
Related reading Súvisiace čítanie
- Plugin Week promises a daily WordPress plugin for a week Plugin týždeň sľubuje denné WordPress plugin pre týždeň
- Follow CNNBrk on Twitter for breaking news updates Postupujte CNNBrk na Twitteru pre aktuality aktualizácie
- How to get Vista theme for Firefox in Windows XP Ako sa dostať Vista theme for Firefox vo Windows XP
- Brighten up Firefox with Camifox theme Rozjasní Firefox s témou Camifox
Hi Sumesh, Hi Sumesh,
Interesting post. Zaujímavý post. I really love tech related stuff, as I can always learn more. Naozaj som rád tech veci týkajúce sa, ako som si vždycky dozvedieť viac. PHP is one of my weak points as I never learned coding. PHP je jedným z mojich slabých stránok, ako som sa nenaučil kódovanie. Only trial by doing kind of stuff and reading about solutions like this is fascinating for me. Iba súd tým, že robí druhu veci a čítanie o riešení, ako je táto, je pre mňa fascinujúce.
Good luck with your entry.:-) Veľa šťastia s vaším vstupom. :-)
Monika Monika
@Monika: Thanks. @ Monika: Vďaka. As regards PHP, neither did I – its just a matter of interest, time and Čo sa týka PHP, já taky ne - to len pre zaujímavosť, času a
elbow grease lakeť tukeffort, plus some cheat sheets to learn PHP (hint: codex.wordpress.org) úsilie, plus niektoré listy podvádzať sa učiť PHP (nápoveda: codex.wordpress.org)That's a great tip Sumesh. To je skvelý tip Sumesh. 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. To môže byť naozaj jednoduché, že si nevšimol týchto chýb v tej dobe a vrátiť sa o niekoľko dní neskôr sa nájsť chyby tam, kde je to najmenej čakáte.
@Andrew: Thanks. @ Andrew: Vďaka. 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. Ako v skutočnosti som chytil túto chybu, keď som zabudol skontrolovať svoje soccerblog.in, ktorý mal chyby, ktoré vidíte na snímke hore.
Thanks.. Vďaka ..
as im not expert in php… im nie ako odborník v php ...
so it helped me alot… and my problem is solved by reading ur post… thanks once again.. tak to mi veľa pomohli ... a môj problém je vyriešený tým, že číta ur post ... vďaka ešte raz ..