Subscribe to RSS feed Subscribe to RSS feed or vai follow me sekojiet man on Twitter? par čivināt?
Haven't you come across some meaningless pile of text, after which nothing is displayed? Nav Jums nākas sastapties ar dažām nenozīmīgs pāļu tekstu, pēc kura nekas nav redzams? It breaks down the whole theme, causing problems for visitors and search bots alike. To iedala visu tēmu, kas rada problēmas, kas apmeklētājiem un meklēt Bots līdzīgi.

Don't we all hate those error codes? Vai nav mēs visi ienīst tos kļūdu kodus?
What are function calls? Kas ir funkcija zvaniem?
Function calls are bits of PHP code that looks like this: <?php ns_show_top_commentators(); ?> Amats zvani ir biti PHP kodu, kas izskatās šādi: <?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. Lielākā daļa plugins ir šāda tagus īpašām vajadzībām; iepriekšminētajiem kods ir uzskaitīt augšpusē komentētāji izmantojot Parādīt Top Atsauksmju spraudni.
The reason Iemesls
PHP function calls are notorious for breaking the theme, if the requested function does not exist. PHP funkcija zvani ir pazīstami ar laužot tēmu, ja pieprasītā funkcija neeksistē. This usually happens when you add a function call for a plugin that you have disabled. Tas parasti notiek, ja jūs pievienojat funkciju aicinājumu spraudni, ka jums ir invalīdiem. The result will be unaccessible blogs, which are caused by the behaviour of broken function calls. Tā rezultātā būs unaccessible blogi, kuru izraisījis uzvedību šķelto funkcija zvani. WordPress cuts off the rendering of page when it stumbles over a broken function all. WordPress izcirtņi pie attēlo lapu, kad tā stumbles pār šķelto funkcija visiem. Thus, depending on where you placed the broken code(sidebar/header/footer), your content may not be displayed, sidebars hidden or footers gone awry. Tādējādi, atkarībā no tā, kur jūs ievietojāt šķelto kods (sānjoslas / header / footer), jūsu saturs nevar būt parādītas, sidebars slēptu vai footers devusies awry.
The solution Šķīdums
This problem can be overcome by using an if function_exists check. Šo problēmu var pārvarēt, izmantojot, if function_exists pārbaudi. What does it do? Ko tā dara? It checks whether the given function actually exists, and if it does, proceeds to call the function. Tas pārbauda, vai dotā funkcija faktiski pastāv, un, ja tas ir, ieņēmumi, lai izsauktu funkciju. This way, your theme will work even when the function call is broken. Tādā veidā, jūsu tēmā darbu pat tad, ja funkcija zvans ir bojāts.
Let us see an example of the conditional code (for Alex King's Twitter Tools plugin, used here on the top navbar). Ļaujiet mums redzēt, piemēram, nosacītā kodu (Alex King's čivināt Rīki spraudnis, kas izmantots šeit uz augšu Navbar).
The normal code for the Twitter tools is this: Normālo kods par čivināt instrumenti ir šādi:
<?php aktt_latest_tweet (); ?>
The conditional code would be this: Nosacītā kods varētu būt šādi:
<?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. To izmantot jebkādiem citiem spraudnis, atrast un kopēt to, kas jums atrast vietā aktt_latest_tweet, pirmkārt kods bloku. Then, paste that part in places of the code in red in the second code block. Pēc tam, pastas, ka daļa vietās kodu sarkanā otrais kods bloku.
This is a bit tricky, but play with it in a Tas ir mazliet viltīgs, bet spēlēt to attiecas test blog installed locally on your PC testa blog uzstādītas lokāli uz datora , and once you get it right, upload it to your server. Un pēc tam, kad jums ir tiesības, augšupielādēt to uz jūsu serveri. Feel free to leave a comment on any issues that crop up on the way. Jūtieties brīvi atstāt komentārus par visiem jautājumiem, kas ražas gada ceļu.
Hi Sumesh, Hi Sumesh,
Interesting post. Interesting post. I really love tech related stuff, as I can always learn more. I really love tech related stuff, kā es vienmēr var uzzināt vairāk. PHP is one of my weak points as I never learned coding. PHP ir viena no manām vājos punktus, kā es nekad nav iemācījušies kodiem. Only trial by doing kind of stuff and reading about solutions like this is fascinating for me. Tikai izmēģinājuma darot veida stuff un lasīšana par risinājumiem, piemēram, tas ir aizraujoši man.
Good luck with your entry.:-) Good luck ar savu ierakstu. :-)
Monika Monika
@Monika: Thanks. @ Monika: Thanks. As regards PHP, neither did I – its just a matter of interest, time and Attiecībā uz PHP, ne did I - tā tikai uz interesi, laiku un
elbow grease smags darbseffort, plus some cheat sheets to learn PHP (hint: codex.wordpress.org) intensitāti, kā arī dažas apkrāptu lapas mācīties PHP (mājiens: codex.wordpress.org)That's a great tip Sumesh. Tas ir liels 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 var tiešām viegli nav paziņojums šīs kļūdas laikā un atgriezties dažas dienas vēlāk, lai atrastu kļūdas, kur tu vismazāk sagaida tiem.
@Andrew: Thanks. @ Andrew: Thanks. 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. Neskatoties uz to, es medīt šī kļūda pēc tam, kad es aizmirsu, lai varētu pārbaudīt savu soccerblog.in, kas bija kļūda redzami screenshot iepriekš.
Thanks.. Thanks ..
as im not expert in php… kā im nav eksperts php ...
so it helped me alot… and my problem is solved by reading ur post… thanks once again.. tāpēc tas palīdzēja man ir daudz ... un mana problēma ir atrisināta, nolasot ur pastu ... paldies vēlreiz ..