Configurer l’extension
Pour créer un widget, il faut, comme pour toute création d’extension, créer un sous-dossier au dossier wp-content/plugins et lui donner un nom. Pour l’exercice, appelez-le « widget-post ».
À l’intérieur du dossier widget-post, créez un fichier widget-post.php. Insérez dans le dossier les fichiers readme.txt, licence.txt et index.php (vide), si vous le souhaitez.
En haut du fichier widget-post.php, ajoutez en en-tête un commentaire avec les informations sur l’extension, et activez l’extension. Puis, vérifiez qu’elle apparaît bien dans l’administration avec les bonnes informations.
Le commentaire est le suivant :
<?php
/*
Plugin Name: Widget post
Description: widget permettant l'affichage d'une liste d'articles
selon la catégorie.
Version: 1.0
License: GPLv2
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License ...