Several WordPress plugins ask you to add certain code to the WordPress theme template files to make them work. Varios plugins de WordPress le pedirá que añada algunas código a la plantilla de WordPress tema de los archivos necesarios para ponerlos en práctica. If you are not a PHP developer or you don’t have time to code review the plugin and you decide to activate the plugin then the plugin can very easily cause your site to crash or worse. Si usted no es un desarrollador de PHP o usted no tiene tiempo de revisión de código el plugin y usted decida activar el plugin entonces el plugin puede provocar muy fácilmente su sitio para colgar o para mal. Often the errors are hard to detect (sporadic, happening only in certain conditions) and even harder to debug as you are not familiar with the code. A menudo los errores son difíciles de detectar (esporádico, sucediendo solamente en ciertas condiciones) y aún más difícil de depurar, como usted no está familiarizado con el código. Today we will talk about a simple step you can take to make your site robust against untested and buggy plugins. Hoy vamos a hablar de un paso simple que usted puede tomar para hacer su sitio robusto contra no sometidos a ensayo y errores de plugins.

Normally most of the time you are asked to include a code block similar to this: Normalmente la mayor parte del tiempo se le pide que incluya un bloque de código similar a este:

The func_name obviously represents a function which the plugin author wants you to include; the arguments are as required for that function. El func_name evidentemente representa una función que el plugin autor quiere que incluyen los argumentos son tan necesarios para esa función.

This can create two major issues. Esto puede crear dos grandes cuestiones.
Firstly if at any time you decide to disable the plugin then you will have to first remove the code from all your template files before you can safely de-activate / remove the plugin. En primer lugar, si en cualquier momento usted decide desactivar el plugin entonces usted tendrá que borrar primero el código de todos sus archivos de plantilla antes de poder en condiciones de seguridad de desactivar o quitar el complemento. Otherwise the pages in the site will fail to load properly. De lo contrario las páginas en el sitio no se carga correctamente.

Secondly the plugin itself may fail in certain conditions or always. En segundo lugar, el propio plugin puede fallar en ciertas condiciones o siempre. In the worst case you will find certain pages on your site fails to load sometimes. En el peor de los casos encontrará algunas páginas de su sitio no se carga a veces. It could be long before you are aware of the problem. Podría ser mucho antes de que sean conscientes del problema.

We will look at two small changes you can make to the code template above to take care of both of the problems described above. Vamos a ver a dos pequeños cambios que puede hacer a la plantilla de código de arriba para cuidar de tanto de los problemas descritos anteriormente. First the modified code: En primer lugar, el código modificado:

if(function_exists(’ func_name ‘) @ func_name( arg1,arg2 …); ?> if (function_exists ( 'func_name') @ func_name (arg1, arg2…);?>
Remember to replace func_name with the actual name of the function. Recuerde reemplazar func_name con el nombre real de la función.

Testing the existence of the function ensures that the code isn’t executed when the plugin is inactive / disabled. Prueba de la existencia de la función asegura que el código no se ejecutará cuando el plugin está inactivo o discapacidades. This prevents the first problem. Esto evita que el primer problema.

Appending an @ before the function name ensures that errors, if any, while executing the function are ignored and do not cause further problems down the road and do not prevent the overall page from displaying. Añadiendo el signo @ antes de que el nombre de función asegura que los errores, en su caso, mientras se ejecuta la función se pasan por alto y no causar más problemas en el camino y no impiden la visualización de la página.

This fix works against all versions of WordPress and also in any other templating system which uses php code. Esto trabaja en contra de fijar todas las versiones de WordPress y también en cualquier otro sistema de plantillas que utiliza el código php.

Carefully make the changes following the template above to make your site more robust against WordPress plugins. Con cuidado, hacer los cambios a raíz de la plantilla anterior para hacer su sitio más robusto contra plugins de WordPress.