¿Algún momento has oído hablar de WordPressWordPress es el software de blogs líder en el mundo, y es concretamente fácil de utilizar y adaptable. Con WordPress, es factible crear con éxito sitios web con la ayuda de funciones ya predefinidas, sin mucho esfuerzo, y para proporcionar contenido como texto, imagen y vídeo. No se requiere conocimiento de HTML. WordPress además facilita la gestión y el mantenimiento de contenidos extensos. Al mismo tiempo de su fácil manejo, plus? Connectable functions? Caso contrario, este postConcepto de Post¿Qué es un Post?Un Post es todo aquel contenido, sea post, opinión, noticia u otro género, que un autor publica en un blog. Este puede ser de carácter corporativo o meramente ocioso; pero siempre tiene como meta arrojar información o reflejar una idea, al mismo tiempo de facilitar que los usuarios encuentren la web donde se recoge por medio de de buscadores y demás plataformas online.Generalmente, se han plus debería llamar su atención. En dos palabras, las funciones conectables son WordPress main functions you can override. All these functions are in a single file: «wp-includes / pluggable.php“. Las funciones conectables se introdujeron en WordPress 1.5.1, pero en las versiones más recientes de WordPress este método ya no se utiliza. Las funciones recientes ahora utilizan filtersConcepto de Filtros¿Qué son los Filtros?Los Filtros son unos mecanismos que, sea en el campo de la informática o en el de las páginas web, se usan para establecer qué tipo de contenidos se deben visualizar o mostrar por pantalla, o cuáles no deben aparecer. Es algo que se emplea en numerosos lugares con fines muy distintos, pero que siempre tiene como objetivo perfilar la búsqueda para acertar mejor con plus en su salida. Pero todavía puede anular las funciones conectables, y esto es lo que me agradaría cubrir en esta publicación.
What functions?
The connectable functions are:
- auth_redirect
- check_admin_referer
- check_ajax_referer
- get_avatar
- get_currentuserinfo
- get_user_by_email
- get_user_by
- get_userdatabylogin
- get_userdata
- is_user_logged_in
- wp_authenticate
- wp_check_password
- wp_clear_auth_cookie
- wp_create_nonce
- wp_generate_auth_cookie
- wp_generate_password
- wp_get_current_user
- wp_hash_password
- wp_hash
- wp_logout
- wp_mail
- wp_new_user_notification
- wp_nonce_tick
- wp_notify_moderator
- wp_notify_postauthor
- wp_parse_auth_cookie
- wp_password_change_notification
- wp_rand
- wp_redirect
- wp_safe_redirect
- wp_salt
- wp_sanitize_redirect
- wp_set_auth_cookie
- wp_set_current_user
- wp_set_password
- wp_text_diff
- wp_validate_auth_cookie
- wp_validate_redirect
- wp_verify_nonce
You can click on the name of each function to enter its codex page.
How to Override Pluggable Features
Well, this is pretty simple, you just have to create a file inside your plugins that contains an "if (! Function_exists ()) ..." statement and then set the function again. I highly recommend that you copy and paste the original feature when you start. This way, you are sure that the function will work. Here is an empty example:
if (! function_exists ('wp_notify_postauthor')): / ** * Notify an author of a comment / trackback / pingback to one of their articles. * * @since 1.0.0 * * @param int $comment_id Comment ID * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback' * @return bool False if user email does not exist. True on completion. * / function wp_notify_postauthor ($comment_id, $comment_type = '') {/ * This is where you redefine the function * /} endif;
I'd like to talk about the "wp_notify_postauthor ()" function. This is responsible for sending an email to the authors of the publication when a new comment is added. In one of my plugins, the WordPress Issue Manager, I needed to disable this notification, but only a specific custom post type. So, I copied the whole function and basically added this:
if (! function_exists ('wp_notify_postauthor')): / ** * Notify an author of a comment / trackback / pingback to one of their articles. * * @since 1.0.0 * * @param int $comment_id Comment ID * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback' * @return bool False if user email does not exist. True on completion. * / function wp_notify_postauthor ($comment_id, $comment_type = '') {if ($post-> post_type! = 'issue'): / * content of the original function * / endif; } endif;
That's simple, but it works great without having to make big changes or create a full custom function tied to a custom action.
wp_mail ()
Como vio en el listado de funciones conectables, wp_mail () es una función conectable. Esta función es la que se usa para enviar correos electrónicos. En cualquier lugar de WordPress, cuando se envía un email, se usa esta función. Es por esto que personalizarlo puede resultar muy interesante. Por ejemplo, puede utilizar una plantilla htmlHTML (Hypertext Markup Language) se usa para estructurar el contenido de texto de un documento web. No sólo se marca el contenido, sino además la meta-información que describe este contenido. Las páginas HTML se almacenan normalmente en el directorio raíz del servidor. Cómo se creó En la era digital, a los usuarios les resulta difícil hallar su camino en las webs y hacer un seguimiento de las estructuras de las plus predeterminada para todos los correos electrónicos enviados desde su instalación de WordPress.
You can also blind copy each message to a specific email to have a kind of backup (trust me, this can be useful when someone tells you that they did not receive the message).
wp_authenticate ()
You can also modify wp_authenticate () and add some additional parameters to strengthen the security of your site (brute force attacks, for example).
auth_redirect ()
This function is the one that checks if a user is logged in and otherwise redirects them to the login page. It would be pretty straightforward to override the function and redirect the user to a custom page, instead of the default login page (for example, if you want to hide the wp-admin folder).
wp_generate_password ()
This function is the one that automatically generates the passwords. It honestly doesn't require modifying, but now that you know what brute force attacks are, you might be interested in creating more secure passwords. Well, this is the function to improve.
conclusion
To wrap up this short post on WordPress pluggable features, I'd like to highlight the fact that new features don't work like this anymore. As I wrote above, they are now using filters. But pluggable features are particularly important features when creating truly specific plugins. But be careful when using pluggable functions. If the newly created function doesn't work great, it may break a part of your web portal (in terms of functionality), so test them under all conditions.




