Subscribe to RSS feed Підписка на RSS канал 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. Він руйнує весь теми, виникають проблеми для відвідувачів і пошукових роботів, так.

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. Більшість плагінів мають такі теги для конкретних цілей; вищезгаданий код є список п'яти найбільш популярних коментаторів, використовуючи Показати Топ Коментатори плагін.
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. В результаті буде недоступний блоги, які викликані поведінкою порушених функцій дзвінків. WordPress cuts off the rendering of page when it stumbles over a broken function all. WordPress відрізає рендеринг сторінок, коли воно спотикається над сломанной функція всіх. Thus, depending on where you placed the broken code(sidebar/header/footer), your content may not be displayed, sidebars hidden or footers gone awry. Таким чином, в залежності від того, де Ви розмістили код сломанной (бокова / верхній і нижній колонтитули), вміст може бути відображено, бічні приховані або нижні колонтитули пішли наперекосяк.
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).
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. Ви можете залишити коментарі з будь-яких питань, які рослинництва вверх по дорозі.
Related reading Схожі читанні
- Follow CNNBrk on Twitter for breaking news updates Слідуйте за щебетати CNNBrk за порушення новин
- Plugin Week promises a daily WordPress plugin for a week Плагін Тиждень обіцяє щоденно плагін для WordPress на тиждень
- How to get Vista theme for Firefox in Windows XP Як отримати Vista тема для Firefox у Windows XP
- Brighten up Firefox with Camifox theme Скрасити Firefox з Camifox тему
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 Моніка
@Monika: Thanks. Monika @: Спасибо. 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)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. Це може бути просто не помічати ці помилки, в той час і повернеться через кілька днів, щоб знайти помилки, якщо ви хоча б очікувати від них.
@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, що помилки ви бачите на скріншот вище.
Thanks.. Спасибо ..
as im not expert in php… як їм не експерт в PHP ...
so it helped me alot… and my problem is solved by reading ur post… thanks once again.. тому він допоміг мені багато ... і моя проблема вирішується шляхом читання ур пост ... спасибо еще раз ..