How To: Add plugin function calls without breaking your theme कैसे: अपने विषय को तोड़ने के बिना प्लगइन समारोह कॉल जोड़ें

ADVERTISEMENT विज्ञापन
To get our software and web/tips via email, sign up for हमारे सॉफ़्टवेयर और वेब ईमेल द्वारा / सुझाव हो, साइन अप करने के लिए daily email newsletter दैनिक ईमेल न्यूज़लेटर . .
Subscribe to RSS feed आरएसएस फ़ीड की सदस्यता लें or या follow me मुझे का पालन करें on Twitter? पर चहचहाना?

Haven't you come across some meaningless pile of text, after which nothing is displayed? क्या तुम नहीं पाठ के कुछ व्यर्थ ढेर में आते हैं, जिसके बाद कुछ भी नहीं दिखाया जाता है? It breaks down the whole theme, causing problems for visitors and search bots alike. यह पूरे विषय टूट जाती है, और आगंतुकों को खोज bots के लिए एक जैसी समस्याओं के कारण.


Don't we all hate those error codes? क्या हम उन सभी त्रुटि कोड से नफरत है?

What are function calls? समारोह फोन क्या हैं?

Function calls are bits of PHP code that looks like this: <?php ns_show_top_commentators(); ?> समारोह कॉल PHP कोड के टुकड़े कर रहे हैं कि इस तरह दिखता है: <?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. सबसे plugins विशिष्ट उपयोगों के लिए ऐसी टैग नहीं है;-उल्लेख कोड के ऊपर से ऊपर दिखाएँ शीर्ष टिप्पणीकारों प्लगइन का उपयोग टिप्पणीकारों की सूची है.

The reason कारण

PHP function calls are notorious for breaking the theme, if the requested function does not exist. PHP समारोह कॉल विषय को तोड़ने के लिए कुख्यात रहे हैं, यदि अनुरोध समारोह में मौजूद नहीं है. This usually happens when you add a function call for a plugin that you have disabled. यह आमतौर पर तब होता है जब आप एक प्लगइन है कि तुम निष्क्रिय कर दिया है के लिए एक समारोह फोन जोड़ें. The result will be unaccessible blogs, which are caused by the behaviour of broken function calls. परिणाम ब्लॉगों unaccessible होगा, जो टूट समारोह कॉल के व्यवहार की वजह से हैं. WordPress cuts off the rendering of page when it stumbles over a broken function all. पृष्ठ के प्रतिपादन से WordPress कटौती यह टूट समारोह की जब सभी stumbles. Thus, depending on where you placed the broken code(sidebar/header/footer), your content may not be displayed, sidebars hidden or footers gone awry. इस प्रकार, पर निर्भर करता है कि तुम कहाँ टूट कोड रखा (साइडबार / शीर्ष / पाद लेख), अपनी सामग्री को प्रदर्शित नहीं किया जा सकता है sidebars छिपा या गड़बड़ा गया footers.

The solution समाधान

This problem can be overcome by using an if function_exists check. इस समस्या का एक if function_exists की जांच का उपयोग करके दूर किया जा सकता है. What does it do? क्या करती है? It checks whether the given function actually exists, and if it does, proceeds to call the function. चेक यह है कि क्या दिया समारोह वास्तव में मौजूद है, और अगर है, आगम है समारोह में बुलाने के लिए. This way, your theme will work even when the function call is broken. इस तरह, आपके विषय काम करेगा जब भी समारोह फोन टूट गया है.

Let us see an example of the conditional code (for Alex King's Twitter Tools plugin, used here on the top navbar). हमें सशर्त कोड (एलेक्स के राजा के लिए चहचहाना उपकरण प्लगइन, टॉप navbar पर यहाँ उपयोग का एक उदाहरण देखें).

ADVERTISEMENT विज्ञापन

The normal code for the Twitter tools is this: चहचहाना उपकरण के लिए सामान्य कोड यह है:
<?php aktt_latest_tweet (); ?>

The conditional code would be this: सशर्त इस कोड होगा:
<?php if(function_exists(' aktt_latest_tweet ')) { aktt_latest_tweet (); } ?> ? <php अगर 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. इसे किसी भी अन्य प्लगइन का उपयोग करते हैं, पता और नकल पहले कोड खंड में आप क्या aktt_latest_tweet के स्थान पर लगता है. Then, paste that part in places of the code in red in the second code block. फिर, चिपकाएँ कि दूसरे कोड खंड में लाल रंग में कोड के स्थानों में भाग.

This is a bit tricky, but play with it in a यह थोड़ा मुश्किल है, लेकिन एक में साथ खेलना test blog installed locally on your PC परीक्षण स्थानीय अपने पीसी पर स्थापित ब्लॉग , and once you get it right, upload it to your server. , और एक बार तुम सही हो, यह आपके सर्वर पर अपलोड करें. Feel free to leave a comment on any issues that crop up on the way. बेझिझक किसी भी मुद्दे पर जिस तरह से फसल पर एक टिप्पणी छोड़ने के लिए.

To get our latest articles, हमारे नवीनतम लेख हो, click here to sign up यहाँ क्लिक करें साइन अप करने के लिए for our free email newsletter or subscribe to हमारे निःशुल्क ईमेल न्यूज़लेटर के लिए या सदस्यता लेने के लिए RSS feed आरएसएस फ़ीड

§ Comments § टिप्पणियाँ
  • Monika @ The Writers Manifesto says: मोनिका @ राइटर्स घोषणापत्र कहते हैं:

    Hi Sumesh, हाय Sumesh,

    Interesting post. रोचक पोस्ट. I really love tech related stuff, as I can always learn more. मैं सच में तकनीक से संबंधित सामान प्यार, जैसा कि मैं हमेशा अधिक सीख सकते हैं. PHP is one of my weak points as I never learned coding. PHP मेरी कमजोर बिंदुओं में से एक के रूप में मैं कोडन कभी नहीं सीखा है. Only trial by doing kind of stuff and reading about solutions like this is fascinating for me. सामान और इस तरह समाधान के बारे में पढ़ने की तरह करके केवल परीक्षण मेरे लिए आकर्षक है.

    Good luck with your entry.:-) अच्छा आपकी प्रविष्टि के साथ भाग्य :-).

    Monika मोनिका

  • Sumesh says: Sumesh कहते हैं:

    @Monika: Thanks. @ मोनिका: धन्यवाद. As regards PHP, neither did I – its just a matter of interest, time and के रूप में PHP का संबंध है, ना ही मैंने किया - अपनी रुचि, समय और का सिर्फ एक मामला elbow grease जिला effort, plus some cheat sheets to learn PHP (hint: codex.wordpress.org) प्रयास से अधिक कुछ शीट धोखा करने PHP सीखना (संकेत: codex.wordpress.org)

  • Andrew says: एंड्रयू कहते हैं:

    That's a great tip Sumesh. यह एक महान टिप 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. यह सच में समय पर इन त्रुटियों को नोटिस और आसान नहीं कर सकते हैं वापस आने के कुछ दिन बाद तुम उन्हें कहाँ त्रुटियों की उम्मीद कम से कम खोजने के लिए.

  • Sumesh says: Sumesh कहते हैं:

    @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. असल में, मैं नीचे यह बग शिकार के बाद मैं अपने soccerblog.in, जो त्रुटि आप ऊपर स्क्रीनशॉट में देख जांच भूल गया था.

  • Haroon says: हारून कहते हैं:

    Thanks.. .. धन्यवाद
    as im not expert in php… IM php में नहीं विशेषज्ञ के रूप में ...
    so it helped me alot… and my problem is solved by reading ur post… thanks once again.. तो मुझे एक बहुत मदद की ... और मेरी समस्या उर पोस्ट पढ़ रहे हैं ... धन्यवाद .. एक बार फिर से हल है

  • § Leave a Reply § एक उत्तर दें छोड़ दो