{"id":770,"date":"2020-04-09T14:50:56","date_gmt":"2020-04-09T14:50:56","guid":{"rendered":"https:\/\/dapliw.org.ve\/?p=770"},"modified":"2020-04-09T14:50:56","modified_gmt":"2020-04-09T14:50:56","slug":"wordpress-5-4-hooks-actions","status":"publish","type":"post","link":"https:\/\/saemas.com\/sitio_web\/wordpress-5-4-hooks-actions\/","title":{"rendered":"WordPress 5.4 &#8211; Hooks (ganchos), actions"},"content":{"rendered":"<p>Cuando necesitamos modificar un plugin no es recomendable hacerlo directamente sobre su c\u00f3digo, sino crear un plugin adicional que aprovecha los hooks (ganchos) que este tiene para colgar el c\u00f3digo que contiene las modificaciones.<\/p>\n<p>Los hooks o ganchos se encuentran distribuidos en puntos estrat\u00e9gicos en el plugin original y se pueden identificar por la instrucci\u00f3n:<\/p>\n<pre><code>do action(nombre-del-gancho, $argumento1, $argumentos2, ...);<\/code><\/pre>\n<p>Para colgar el c\u00f3digo de nuestro nuevo plugin, escribimos:<\/p>\n<pre><code>add_action( 'nombre-del-hook', 'nombre-de-mi-funcion', 10, 1 );\nfunction nombre-de-mi-funcion( $argumento1_ ) \n{\n    echo \"Hola mundo, este es el valor de \" . $argumento1; \n}<\/code><\/pre>\n<p>Fuente:<\/p>\n<p><a href=\"https:\/\/docs.presscustomizr.com\/article\/26-wordpress-actions-filters-and-hooks-a-guide-for-non-developers\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.presscustomizr.com\/article\/26-wordpress-actions-filters-and-hooks-a-guide-for-non-developers<\/a><\/p>\n<p><a href=\"https:\/\/developer.wordpress.org\/plugins\/hooks\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/developer.wordpress.org\/plugins\/hooks\/<\/a><\/p>\n<p>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cuando necesitamos modificar un plugin no es recomendable hacerlo directamente sobre su c\u00f3digo, sino crear un plugin adicional que aprovecha los hooks (ganchos) que este tiene para colgar el c\u00f3digo que contiene las modificaciones. Los hooks o ganchos se encuentran distribuidos en puntos estrat\u00e9gicos en el plugin original y se pueden identificar por la instrucci\u00f3n: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":782,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"material-hide-sections":[],"footnotes":""},"categories":[21],"tags":[22],"class_list":["post-770","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/posts\/770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/comments?post=770"}],"version-history":[{"count":0,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/posts\/770\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/media?parent=770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/categories?post=770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/tags?post=770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}