{"id":1657,"date":"2022-12-16T10:00:00","date_gmt":"2022-12-16T16:00:00","guid":{"rendered":"http:\/\/racmanuel.dev\/?p=1657"},"modified":"2023-03-24T09:57:26","modified_gmt":"2023-03-24T15:57:26","slug":"como-hacer-un-plugin-para-wordpress","status":"publish","type":"post","link":"https:\/\/racmanuel.dev\/en\/como-hacer-un-plugin-para-wordpress\/","title":{"rendered":"How to make a WordPress plugin?"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Creating a plugin for WordPress is very simple, more than you might imagine, but before developing a plugin, we must first understand some concepts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"que-es-un-plugin\"><span style=\"color: var(--theme-palette-color-2, #25ff00);\" class=\"stk-highlight\">What is a Plugin?<\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A plugin is a package of code that extends the core functionality of WordPress. WordPress plugins are composed of PHP code and may include other files such as images, CSS, and JavaScript.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When creating a plugin, we are extending WordPress, meaning we are building additional functionality on top of what WordPress already offers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or, using WordPress custom post types, we can write a plugin that creates a fully functional support ticket system with email notifications, custom ticket statuses, and a client-facing portal. The only limit is imagination\u2014the possibilities are endless!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Most WordPress plugins consist of many files, but a plugin actually only needs one main file written in PHP with a specific format in the header.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once this concept is clarified, we can begin creating our first WordPress plugin.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"como-hacer-un-plugin-para-wordpress\"><span style=\"color: var(--theme-palette-color-2, #25ff00);\" class=\"stk-highlight\">How to make a WordPress plugin?<\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An example of a plugin that I recommend every user create is one that replaces the functions.php file, which is typically located in the folder of the active theme. To this, I recommend adding functions and actions; in fact, some functions make more sense as a plugin than as an addition to a theme. So, for your first plugin, do not hesitate to create a substitute for functions.php. However, after mentioning this, I will explain the process to create and start working with a plugin, which is as simple as this:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create the plugin file with the standard header so that WordPress recognizes it as such and it can be installed and activated.<\/li>\n\n\n\n<li>Add functions, actions, and filters.<\/li>\n\n\n\n<li>Compress the file into a ZIP and upload it via the plugin installer or via FTP.<\/li>\n\n\n\n<li>Activate it like any other plugin.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The standard header of a WordPress plugin follows very simple rules, as seen in the example:<\/p>\n\n\n\n<pre title=\"\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php line-numbers\">&lt;?php<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Basically, these lines of code indicate the plugin name, plugin URL, author, plugin description, and the license it holds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The next step is to add, below the header we previously created, those WordPress functions or PHP code that will execute upon activation. Logically, if you do not know how to program in PHP, the tutorial ends here. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the following example, several functions have already been added:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">What are the final steps? Save the changes and give your plugin a catchy name. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once you upload it to your WordPress installation, if you have not made any coding mistakes, you can activate it like any other plugin and enjoy its wonders.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"130\" src=\"http:\/\/racmanuel.dev\/wp-content\/uploads\/image-62-1024x130.png\" alt=\"\" class=\"wp-image-1700\" title=\"\" srcset=\"https:\/\/racmanuel.dev\/wp-content\/uploads\/image-62-1024x130.png 1024w, https:\/\/racmanuel.dev\/wp-content\/uploads\/image-62-600x76.png 600w, https:\/\/racmanuel.dev\/wp-content\/uploads\/image-62-300x38.png 300w, https:\/\/racmanuel.dev\/wp-content\/uploads\/image-62-768x97.png 768w, https:\/\/racmanuel.dev\/wp-content\/uploads\/image-62.png 1095w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Plugin ready to activate.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><span style=\"color: var(--theme-palette-color-2, #25ff00);\" class=\"stk-highlight\">Conclusion<\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Plugins in WordPress are code packages that allow us developers to extend the core functionality of WordPress. WordPress plugins are composed of PHP code and may include other assets such as images, CSS, and JavaScript. By creating your own plugin, we are&nbsp;<em>extending<\/em>&nbsp;WordPress, that is, building additional functionality on top of what WordPress already offers. The possibilities are&nbsp;<em>endless!<\/em> The only limit is your imagination.<\/p>","protected":false},"excerpt":{"rendered":"<p>A plugin is a package of code that extends the core functionality of WordPress. WordPress plugins are composed of PHP code and may include other files such as images, CSS, and JavaScript.<\/p>\n<p>When creating a plugin, we are extending WordPress, meaning we are building additional functionality on top of what WordPress already offers.<\/p>","protected":false},"author":1,"featured_media":1713,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","_glsr_average":0,"_glsr_ranking":0,"_glsr_reviews":0,"footnotes":""},"categories":[48],"tags":[],"niveles":[],"class_list":["post-1657","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutoriales"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"acf":[],"_links":{"self":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/1657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/comments?post=1657"}],"version-history":[{"count":8,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/1657\/revisions"}],"predecessor-version":[{"id":1714,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/1657\/revisions\/1714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/media\/1713"}],"wp:attachment":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/media?parent=1657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/categories?post=1657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/tags?post=1657"},{"taxonomy":"niveles","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/niveles?post=1657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}