{"id":2223,"date":"2023-06-02T10:00:00","date_gmt":"2023-06-02T15:00:00","guid":{"rendered":"http:\/\/racmanuel.dev\/?p=2223"},"modified":"2023-05-27T19:28:04","modified_gmt":"2023-05-28T00:28:04","slug":"crea-un-plugin-de-wordpress-con-vue-js-en-la-parte-de-administracion","status":"publish","type":"post","link":"https:\/\/racmanuel.dev\/en\/crea-un-plugin-de-wordpress-con-vue-js-en-la-parte-de-administracion\/","title":{"rendered":"Create a WordPress plugin with Vue.js in the admin area"},"content":{"rendered":"<h2 class=\"wp-block-heading\" id=\"introduccion\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, you will learn how to develop a WordPress plugin using Vue.js in the admin area. Combining the power of WordPress and Vue.js will allow you to create interactive and dynamic user interfaces for your plugin. The final result will be an admin page displaying a message generated by Vue.js.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"678\" src=\"http:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-574080-1024x678.jpeg\" alt=\"person wearing black watch holding macbook pro\" class=\"wp-image-2226\" title=\"\" srcset=\"https:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-574080-1024x678.jpeg 1024w, https:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-574080-600x397.jpeg 600w, https:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-574080-300x199.jpeg 300w, https:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-574080-768x509.jpeg 768w, https:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-574080-1536x1017.jpeg 1536w, https:\/\/racmanuel.dev\/wp-content\/uploads\/pexels-photo-574080.jpeg 1880w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Photo by Lukas on [Unsplash] <a href=\"https:\/\/www.pexels.com\/photo\/person-wearing-black-watch-holding-macbook-pro-574080\/\" rel=\"nofollow noopener\" target=\"_blank\">Pexels.com<\/a><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-1-configurar-el-entorno\">Step 1: Set up the environment:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Ensure you have a WordPress installation on your local or remote server.<\/li>\n\n\n\n<li>Create a folder for your plugin inside the \u201cwp-content\/plugins\u201d directory of your WordPress installation.<\/li>\n\n\n\n<li>Inside your plugin folder, create a file named \u201cindex.php\u201d.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-2-anadir-el-codigo-del-plugin\">Step 2: Add the plugin code:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the \u201cindex.php\u201d file and add the following code:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php;\r\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Save the file.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-3-crear-el-archivo-del-script-personalizado\">Step 3: Create the custom script file:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a folder named \u201cassets\u201d inside your plugin folder.<\/li>\n\n\n\n<li>Inside the \u201cassets\u201d folder, create a folder named \u201cjs\u201d.<\/li>\n\n\n\n<li>Inside the \u201cjs\u201d folder, create a file named \u201cplugin.js\u201d.<\/li>\n\n\n\n<li>Open the \u201cplugin.js\u201d file and add the following code:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">document.addEventListener('DOMContentLoaded', function() {;\r<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Save the file.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-4-crear-la-pagina-de-administracion\">Step 4: Create the admin page:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the \u201cindex.php\u201d file again and add the following code:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">function wp_vue_admin_page() {\r\n    echo &#039;&lt;div id=&quot;your-plugin-admin&quot;&gt;&#039;;&#039;&lt;h1&gt;{{ message }}&lt;\/h1&gt;&#039;;&#039;&lt;\/div&gt;&#039;;\r\n}\r\n\r\nfunction wp_vue_admin_menu() {\r\n    add_menu_page(\r\n        &#039;Tu Plugin de WordPress&#039;,\r\n        &#039;Tu Plugin&#039;,\r\n        &#039;manage_options&#039;,\r\n        &#039;your-plugin-admin&#039;,\r\n        &#039;wp_vue_admin_page&#039;,\r\n        &#039;dashicons-admin-generic&#039;,\r\n        99\r\n    );\r\n}\r\nadd_action( &#039;admin_menu&#039;, &#039;wp_vue_admin_menu&#039; );\r<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Save the file.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-5-activar-el-plugin\">Step 5: Activate the plugin:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to your WordPress admin dashboard.<\/li>\n\n\n\n<li>Navigate to the \u201cPlugins\u201d section.<\/li>\n\n\n\n<li>Find your plugin's name in the list and click \u201cActivate\u201d.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"paso-6-verificar-el-resultado\">Step 6: Verify the result:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to the \u201cYour Plugin\u201d section in the admin dashboard.<\/li>\n\n\n\n<li>You should see a message saying \u201cHello from Vue.js!\u201d generated by Vue.js.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion: <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, you have learned how to develop a WordPress plugin using Vue.js in the admin area. You can now leverage Vue.js capabilities to create interactive and dynamic user interfaces in your WordPress plugin. Explore more about Vue.js and customize your plugin according to your needs!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remember that this tutorial provides a basic introduction to getting started with Vue.js in the WordPress admin area. As you become more familiar with Vue.js, you will be able to implement more advanced features and extend your plugin's functionality. Enjoy programming with Vue.js and WordPress!<\/p>\n\n\n<style><\/style><style><\/style>\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading has-large-font-size\" id=\"necesitas-ayuda-con-un-proyecto-web\">Do you need help with a web project?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Do you need help with a web project? Don&#039;t hesitate to contact me. I develop complete and customized solutions with WordPress and PHP, using modern tools and processes, HTML, CSS, SCSS, PHP, JavaScript, Bootstrap, and more. Ready? Send me a message and let&#039;s talk about your web project!<\/p>\n\n\n<div class=\"wp-block-groundhogg-forms\">\n\t<div class=\"gh-form-wrapper\"><form method=\"post\" class=\"gh-form gh-form-v2\" target=\"_parent\" enctype=\"multipart\/form-data\" name=\"Formulario de Contacto\" id=\"gh-form-24\" data-id=\"24\" action=\"\"><div class=\"gh-form-fields\"><div class=\"gh-form-column col-1-of-2\"><label for=\"first_name\">Name <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"text\" name=\"first_name\" id=\"first_name\" class=\"gh-input gh-first-name\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-2\"><label for=\"last_name\">Last name(s) <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"text\" name=\"last_name\" id=\"last_name\" class=\"gh-input gh-last-name\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"email\">Email <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"email\" name=\"email\" id=\"email\" class=\"gh-input gh-email\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"primary_phone\">Phone or WhatsApp <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><input type=\"tel\" name=\"primary_phone\" id=\"primary_phone\" class=\"gh-input\" value=\"\" required><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"nombre_de_tu_negocio_o_empresa\">Name of your Business or Company<\/label><div class=\"gh-form-input-field\"><input type=\"text\" name=\"nombre_de_tu_negocio_o_empresa\" id=\"nombre_de_tu_negocio_o_empresa\" class=\"gh-input\" value=\"\"\/><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"link_de_tu_pagina_web\">Link to your website<\/label><div class=\"gh-form-input-field\"><input type=\"url\" name=\"link_de_tu_pagina_web\" id=\"link_de_tu_pagina_web\" class=\"gh-input\" value=\"\" placeholder=\"If your business or company has a website, enter the link here.\"\/><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"question_type\">What kind of question do you have? <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><select name=\"question_type\" id=\"question_type\" class=\"gh-input\" required><option value=\"Cotizaci\u00f3n\">Price<\/option><option value=\"General\">General<\/option><option value=\"Soporte\">Medium<\/option><\/select><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><label for=\"message\">Ask <span class=\"required\">*<\/span><\/label><div class=\"gh-form-input-field\"><textarea name=\"message\" id=\"message\" class=\"gh-input\" rows=\"7\" placeholder=\"Your question or doubt...\" type=\"text\" required><\/textarea><\/div><\/div><div class=\"gh-form-column col-1-of-1\"><div class=\"consent gh-gdpr\" id=\"gdpr_consent\"><div ><label class=\"gh-checkbox-label\"><input type=\"checkbox\" name=\"data_processing_consent\" id=\"data-processing-consent\" class=\"\" value=\"yes\" required><span class=\"checkbox-label\">I agree to racmanuel.dev&#8217;s storage and processing of my personal data. <span class=\"required\">*<\/span><\/span><\/label><\/div><div ><label class=\"gh-checkbox-label\"><input type=\"checkbox\" name=\"marketing_consent\" id=\"marketing-consent\" class=\"\" value=\"yes\"\/><span class=\"checkbox-label\">I agree to receive marketing offers and updates from racmanuel.dev.<\/span><\/label><\/div><\/div><\/div><div class=\"gh-form-column col-1-of-3\"><button type=\"submit\" class=\"gh-submit gh-button primary\" value=\"\">Get in touch!<\/button><\/div><\/div><input type=\"hidden\" name=\"trp-form-language\" value=\"en\"\/><\/form><\/div><\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Combining the power of WordPress and Vue.js will allow you to create interactive and dynamic user interfaces for your plugin. The final result will be an admin page displaying a message generated by Vue.js.<\/p>","protected":false},"author":1,"featured_media":2226,"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":[42],"niveles":[38],"class_list":["post-2223","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutoriales","tag-wordpress","niveles-intermedio"],"blocksy_meta":[],"acf":[],"_links":{"self":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/2223","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=2223"}],"version-history":[{"count":3,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/2223\/revisions"}],"predecessor-version":[{"id":2227,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/posts\/2223\/revisions\/2227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/media\/2226"}],"wp:attachment":[{"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/media?parent=2223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/categories?post=2223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/tags?post=2223"},{"taxonomy":"niveles","embeddable":true,"href":"https:\/\/racmanuel.dev\/en\/wp-json\/wp\/v2\/niveles?post=2223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}