How To: Add plugin function calls without breaking your theme How To: Add plugin functie aanroepen zonder te breken uw thema

ADVERTISEMENT ADVERTISEMENT
To get our software and web/tips via email, sign up for Om onze software en web / tips via e-mail, meld u aan voor daily email newsletter dagelijkse e-mail nieuwsbrief . .
Subscribe to RSS feed Abonneren op RSS-feed or of follow me follow me on Twitter? op Twitter?

Haven't you come across some meaningless pile of text, after which nothing is displayed? Heb je niet tegenkomen zinloos stapel van de tekst, waarna er niets wordt weergegeven? It breaks down the whole theme, causing problems for visitors and search bots alike. Het breekt het hele thema, veroorzaakt problemen voor bezoekers en zoekrobots gelijk.


Don't we all hate those error codes? We niet allemaal haat die foutcodes?

What are function calls? Wat zijn functie aanroepen?

Function calls are bits of PHP code that looks like this: <?php ns_show_top_commentators(); ?> Functie gesprekken zijn stukjes PHP-code die er als volgt uitziet: <?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. De meeste plugins zijn dergelijke tags voor specifieke toepassingen; de bovengenoemde code is om de top commentatoren met behulp van de Toon Top Commentatoren plugin lijst.

The reason De reden

PHP function calls are notorious for breaking the theme, if the requested function does not exist. PHP functie gesprekken zijn berucht voor het breken van het thema, indien de gevraagde functie niet bestaat. This usually happens when you add a function call for a plugin that you have disabled. Dit gebeurt meestal wanneer u een functie oproep voor een plugin die u hebt uitgeschakeld. The result will be unaccessible blogs, which are caused by the behaviour of broken function calls. Het resultaat zal zijn ontoegankelijk blogs, die worden veroorzaakt door het gedrag van gebroken functie oproepen. WordPress cuts off the rendering of page when it stumbles over a broken function all. WordPress snijdt de rendering van de pagina als het struikelt over een gebroken functie. Thus, depending on where you placed the broken code(sidebar/header/footer), your content may not be displayed, sidebars hidden or footers gone awry. Zo, afhankelijk van waar je de gebroken code geplaatst (sidebar / header / footer), kan uw inhoud niet worden weergegeven, sidebars verborgen of voetteksten verkeerd gegaan.

The solution De oplossing

This problem can be overcome by using an if function_exists check. Dit probleem kan worden opgelost met behulp van een if function_exists controleren. What does it do? Wat doet het? It checks whether the given function actually exists, and if it does, proceeds to call the function. Het controleert of de gegeven functie daadwerkelijk bestaat, en zo ja, zijn opbrengsten te bellen naar de functie. This way, your theme will work even when the function call is broken. Op deze manier zal uw thema werken, zelfs wanneer de functie oproep is verbroken.

Let us see an example of the conditional code (for Alex King's Twitter Tools plugin, used here on the top navbar). Laten we een voorbeeld van de voorwaardelijke code (voor Alex King's Twitter Tools plugin, hier gebruikt op de bovenste navigatiebalk).

ADVERTISEMENT ADVERTISEMENT

The normal code for the Twitter tools is this: De normale code voor de Twitter gereedschap is dit:
<?php aktt_latest_tweet (); ?>

The conditional code would be this: De voorwaardelijke code zou dit zijn:
<?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. Om het te gebruiken voor andere plugin, vinden en kopieer wat je kunt vinden in plaats van aktt_latest_tweet in de eerste code blok. Then, paste that part in places of the code in red in the second code block. Plak dat deel in plaatsen van de code in het rood in de tweede code te blokkeren.

This is a bit tricky, but play with it in a Dit is een beetje lastig, maar spelen in een test blog installed locally on your PC test blog lokaal op uw PC geïnstalleerd , and once you get it right, upload it to your server. , En zodra je het goed, uploaden naar uw server. Feel free to leave a comment on any issues that crop up on the way. Voel je vrij om commentaar achter te laten over eventuele problemen die opduiken op de weg.

To get our latest articles, Om onze nieuwste artikelen, click here to sign up klik hier om in te schrijven for our free email newsletter or subscribe to voor onze gratis e-nieuwsbrief of abonneer op RSS feed RSS

§ Comments § Reacties
  • Monika @ The Writers Manifesto says: Monika @ The Writers Manifest zegt:

    Hi Sumesh, Hi Sumesh,

    Interesting post. Interessante post. I really love tech related stuff, as I can always learn more. I really love tech-gerelateerde dingen, zoals ik altijd meer kan leren. PHP is one of my weak points as I never learned coding. PHP is een van mijn zwakke punten zoals ik nooit geleerd codering. Only trial by doing kind of stuff and reading about solutions like this is fascinating for me. Alleen door het doen van onderzoek soort dingen en lezen over oplossingen zoals deze is fascinerend voor mij.

    Good luck with your entry.:-) Veel succes met uw invoer. :-)

    Monika Monika

  • Sumesh says: Sumesh zegt:

    @Monika: Thanks. @ Monika: Thanks. As regards PHP, neither did I – its just a matter of interest, time and Met betrekking tot PHP, noch heb ik - zijn slechts een kwestie van belangstelling, tijd en elbow grease spierballen effort, plus some cheat sheets to learn PHP (hint: codex.wordpress.org) inspanning, plus een aantal vellen cheat om PHP te leren (hint: codex.wordpress.org)

  • Andrew says: Andrew zegt:

    That's a great tip Sumesh. Dat is een geweldige 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. Het kan echt niet gemakkelijk zijn om deze fouten op het moment aankondiging en kom terug een paar dagen later te vinden fouten waar je ze het minst verwacht.

  • Sumesh says: Sumesh zegt:

    @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. In feite, gejaagd ik van deze bug nadat ik vergat om mijn soccerblog.in, waar de fout zie je in de screenshot hierboven had te controleren.

  • Haroon says: Haroon zegt:

    Thanks.. Thanks ..
    as im not expert in php… als im geen expert in php ...
    so it helped me alot… and my problem is solved by reading ur post… thanks once again.. dus het is me veel geholpen ... en mijn probleem wordt opgelost door het lezen van ur post ... bedankt weer ..

  • § Leave a Reply § Leave a Reply