{"id":232498,"date":"2023-01-15T15:44:00","date_gmt":"2023-01-15T12:44:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232498"},"modified":"2023-01-15T15:52:38","modified_gmt":"2023-01-15T12:52:38","slug":"tutorial-sui-plugin-di-wordpress-come-scrivere-il-primo-plugin","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/it\/tutorial-sui-plugin-di-wordpress-come-scrivere-il-primo-plugin\/","title":{"rendered":"Tutorial sui plugin di WordPress &#8211; Come scrivere il primo plugin?"},"content":{"rendered":"<p><a href=\"https:\/\/helloacm.com\/forum\/seo-wordpress-coding-for-the-web\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">WordPress<\/a> \u00e8 cos\u00ec potente perch\u00e9 puoi scrivere plugin per esso. I plugin sono utili da gestire e non saranno interessati se aggiorni\/cambia temi o aggiorni i core di wordpress. Scrivere un plugin per wordpress \u00e8 facile.<\/p>\n<h3>Cartella dei plug-in<\/h3>\n<p><a href=\"https:\/\/helloacm.com\/topic\/seo-wordpress-coding-for-the-web\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">I plugin di WordPress<\/a> sono memorizzati nella cartella \/wp-content\/plugins. Ogni plugin ha la sua cartella. La voce del <a href=\"https:\/\/wordpress.mediadoma.com\/it\/il-plug-in-wp-rocket-la-riscrittura-https-automatica-non-riesce-a-convalidare-lamp\/\" title=\"plugin\">plugin<\/a> dovrebbe essere il file php che ha lo stesso nome della cartella. Ad esempio, se assegni un nome alla cartella sample, dovresti creare un file sample.php in quella cartella.<\/p>\n<h3>Plugin Metadati<\/h3>\n<p>Affinch\u00e9 <a href=\"https:\/\/helloacm.com\/multilingual-bug-fix-php-7-wordpress-4-4-compatibility-wp-rocket-2-6-14\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">WordPress<\/a> possa capire il tuo plugin, devi inserire un commento all&#8217;interno del file php del plugin (all&#8217;inizio).<\/p>\n<pre><code>&lt;php\n\/*\nPlugin Name: Plugin Name\nDescription: Plugin Description\nVersion: 0.1\nAuthor: SteakOverCooked\nAuthor URI: &lt;a class=\"vglnk\" target=\"_blank\" href=\"https:\/\/steakovercooked.com\" rel=\"nofollow\"&gt;&lt;span&gt;https&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;steakovercooked&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;com&lt;\/span&gt;&lt;\/a&gt;\nPlugin URI: &lt;a class=\"vglnk\" target=\"_blank\" href=\"https:\/\/steakovercooked.com\" rel=\"nofollow\"&gt;&lt;span&gt;https&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;steakovercooked&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;com&lt;\/span&gt;&lt;\/a&gt;\nLicense: Free\nText Domain: sample-plugin\n*\/<\/code><\/pre>\n<h3>Primo plugin<\/h3>\n<p>Sulla base di <a href=\"https:\/\/helloacm.com\/disable-spam-comments-in-wordpress-by-checking-referer\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">questo post<\/a>, possiamo creare un plugin che blocca la maggior parte dei commenti spam controllando la variabile <strong>HTTP_REFERER .<\/strong><\/p>\n<pre><code>&lt;?php\n\/*\nPlugin Name: Check Comment Flood\nDescription: This Simple Plugin prevents most of the spam comments by checking the HTTP_REFERER variable. No complex configurations just simply activating the plugin will do the job. \nVersion: 0.1\nAuthor: SteakOverCooked\nAuthor URI: &lt;a class=\"vglnk\" target=\"_blank\" href=\"https:\/\/steakovercooked.com\" rel=\"nofollow\"&gt;&lt;span&gt;https&lt;\/span&gt;&lt;span&gt;:\/\/&lt;\/span&gt;&lt;span&gt;steakovercooked&lt;\/span&gt;&lt;span&gt;.&lt;\/span&gt;&lt;span&gt;com&lt;\/span&gt;&lt;\/a&gt;\nPlugin URI: \nLicense: Free\nText Domain: check-comment-flood \n*\/\n\u00a0\nfunction check_referrer() {\n\u00a0 \u00a0 if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == '') {\n\u00a0 \u00a0 \u00a0 \u00a0 wp_die(__('Please do not access this file directly.'));\n\u00a0 \u00a0 }\n}\nadd_action('check_comment_flood', 'check_referrer');<\/code><\/pre>\n<p>Salva il file e aggiorna la pagina del plugin, vedrai questo:<\/p>\n<p><a href=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-157159-61e5cef3484e6.jpg\" data-rel=\"lightbox\"><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-157159-61e5cef3484e6.jpg\" alt=\"Tutorial sui plugin di Wordpress - Come scrivere il primo plugin?\"><\/a><\/p>\n<p>primo plugin per wordpress<\/p>\n<h3>Com&#8217;\u00e8 meglio?<\/h3>\n<p>Puoi facilmente attivare e disattivare il plug-in. Non \u00e8 necessario modificare direttamente il template della funzione (se qualcosa va storto, il wordpress morir\u00e0). Se incasini il plug-in, il plug-in verr\u00e0 semplicemente disattivato. Puoi anche aggiornare il plugin particolare (facile da mantenere).<\/p>\n<p>Non devi fare nulla se aggiorni wordpress o i file del tema.<\/p>\n<p>github: <a href=\"https:\/\/github.com\/DoctorLai\/check-comment-flood\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">controlla il flusso di commenti<\/a><\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Fonte di registrazione:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tutorial sui plugin di WordPress \u2013 Come scrivere il primo plugin?<\/p>\n","protected":false},"author":1,"featured_media":223841,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[896,835,804,814,720,844,865],"tags":[1168],"class_list":["post-232498","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codice","category-guida-per-principianti","category-php-6","category-plugin-2","category-sviluppatore","category-tutorial","category-wordpress-6","tag-affiai-it"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts\/232498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/comments?post=232498"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/posts\/232498\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/media\/223841"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/media?parent=232498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/categories?post=232498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/it\/wp-json\/wp\/v2\/tags?post=232498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}