How To: Add plugin function calls without breaking your theme How To: Fügen Sie das Plugin-Funktion aufruft, ohne zu brechen Ihr Thema

ADVERTISEMENT WERBUNG
To get our software and web/tips via email, sign up for Um unsere Software-und Web-get / Tipps per E-Mail, melden Sie sich für daily email newsletter täglich per E-Mail-Newsletter . .
Subscribe to RSS feed RSS-Feed abonnieren or oder follow me Follow me on Twitter? auf Twitter?

Haven't you come across some meaningless pile of text, after which nothing is displayed? Hast du nicht auf einige sinnlose Haufen Text, nach der nichts angezeigt wird? It breaks down the whole theme, causing problems for visitors and search bots alike. Sie gliedern sich die ganze Thematik, was zu Problemen für Besucher und Suchrobotern gleichermaßen.


Don't we all hate those error codes? Sind wir nicht alle hasse diese Fehlercodes?

What are function calls? Welche Funktion aufruft?

Function calls are bits of PHP code that looks like this: <?php ns_show_top_commentators(); ?> Funktionsaufrufe sind Bits von PHP-Code, der wie folgt aussieht: <?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. Die meisten Module haben solche Tags für spezielle Anwendungen, die oben genannten Code wird der Top-Kommentatoren über die Karte Top-Kommentatoren Plugin-Liste.

The reason Der Grund

PHP function calls are notorious for breaking the theme, if the requested function does not exist. PHP-Funktion Anrufe sind zum Brechen des berüchtigten Thema, wenn die angeforderte Funktion nicht vorhanden ist. This usually happens when you add a function call for a plugin that you have disabled. Dies passiert meist, wenn Sie eine Funktion aufrufen, fügen Sie für ein Plugin, dass Sie deaktiviert haben. The result will be unaccessible blogs, which are caused by the behaviour of broken function calls. Das Ergebnis wird unzugänglich Blogs, die durch das Verhalten von Defekten Funktionsaufrufe verursacht werden. WordPress cuts off the rendering of page when it stumbles over a broken function all. WordPress schneidet die Darstellung der Seite, wenn es stolpert über eine gebrochene Funktion alle. Thus, depending on where you placed the broken code(sidebar/header/footer), your content may not be displayed, sidebars hidden or footers gone awry. So, je nachdem, wo Sie den Code platziert defekt (sidebar / header / footer), kann Ihre Inhalte nicht angezeigt werden, Seitenleisten versteckt oder Fußzeilen schief gegangen.

The solution Die Lösung

This problem can be overcome by using an if function_exists check. Dieses Problem kann durch die Verwendung ein, if function_exists überprüfen überwunden werden. What does it do? Was tut es? It checks whether the given function actually exists, and if it does, proceeds to call the function. Es prüft, ob die angegebene Funktion tatsächlich existiert, und wenn dies der Fall, die Einnahmen der Funktion aufrufen. This way, your theme will work even when the function call is broken. Auf diese Weise wird Ihr Thema zu arbeiten, auch wenn die Funktion aufrufen gebrochen ist.

Let us see an example of the conditional code (for Alex King's Twitter Tools plugin, used here on the top navbar). Lassen Sie uns ein Beispiel für die bedingte Code (für Alex King's Twitter Tools Plugin, hier in der oberen Navigationsleiste) verwendet.

ADVERTISEMENT WERBUNG

The normal code for the Twitter tools is this: Der normale Code für die Twitter Tools ist dies:
<?php aktt_latest_tweet (); ?>

The conditional code would be this: Die bedingte Code würde lauten:
<?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. Um es für alle anderen Plugin zu verwenden, zu finden und kopieren Sie das, was Sie an Stelle von aktt_latest_tweet finden Sie in der ersten Code-Block. Then, paste that part in places of the code in red in the second code block. Anschließend fügen, die an Orten der Code in Rot in der zweiten Code-Block.

This is a bit tricky, but play with it in a Das ist ein bisschen schwierig, aber mit ihm spielen in einem test blog installed locally on your PC Test-Blog lokal auf Ihrem PC installiert , and once you get it right, upload it to your server. , Und wenn man es richtig, laden Sie sie auf Ihren Server. Feel free to leave a comment on any issues that crop up on the way. Fühlen Sie frei, um einen Kommentar über alle Probleme, die auftauchen, auf dem Weg.

To get our latest articles, Um unsere neuesten Artikel, click here to sign up Klicken Sie hier, um sich anzumelden for our free email newsletter or subscribe to für unseren kostenlosen E-Mail-Newsletter oder zur Zeichnung von RSS feed RSS-Feed

§ Comments § Kommentare
  • Monika @ The Writers Manifesto says: Monika @ The Writers Manifest sagt:

    Hi Sumesh, Hallo Sumesh,

    Interesting post. Interessanter Beitrag. I really love tech related stuff, as I can always learn more. I really love Tech-related stuff, da kann ich immer mehr zu erfahren. PHP is one of my weak points as I never learned coding. PHP ist eine meiner Schwächen, wie ich es nie gelernt Codierung. Only trial by doing kind of stuff and reading about solutions like this is fascinating for me. Nur Versuch, indem Sie solche Sachen und Lesen über Lösungen wie das ist für mich faszinierend.

    Good luck with your entry.:-) Viel Glück mit Ihrem Eintrag. :-)

    Monika Monika

  • Sumesh says: Sumesh sagt:

    @Monika: Thanks. @ Monika: Danke. As regards PHP, neither did I – its just a matter of interest, time and In Bezug auf PHP, ich auch nicht - die nur eine Frage von Interesse, Zeit und elbow grease Elbow Grease effort, plus some cheat sheets to learn PHP (hint: codex.wordpress.org) Anstrengungen, sowie einige Spickzettel PHP lernen (Tipp: codex.wordpress.org)

  • Andrew says: Andrew sagt:

    That's a great tip Sumesh. Das ist ein guter Tipp 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. Es kann wirklich nicht leicht, diese Fehler bei der Bekanntmachung und wieder ein paar Tage später, um Fehler, wo man sie am wenigsten erwarten finden.

  • Sumesh says: Sumesh sagt:

    @Andrew: Thanks. @ Andrew: Danke. 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 der Tat, ich jagte diesen Fehler, nachdem ich vergessen, meine soccerblog.in, die den Fehler, den du im obigen Screenshot zu überprüfen hatte.

  • Haroon says: Haroon sagt:

    Thanks.. Thanks ..
    as im not expert in php… wie im nicht Experte in php ...
    so it helped me alot… and my problem is solved by reading ur post… thanks once again.. so ist es mir sehr geholfen ... und mein Problem wird durch das Lesen ur post ... noch einmal vielen Dank .. gelöst

  • § Leave a Reply § Lassen Sie eine Antwort