Created
December 19, 2022 14:42
-
-
Save thierrypigot/84926120ba3a084f52251fd35d454fbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Mon_Widget extends WP_Widget { | |
| // Définit le constructeur | |
| function __construct() { | |
| $widget_ops = array( | |
| 'classname' => 'mon_widget', | |
| 'description' => 'Affiche le titre du site Web.' | |
| ); | |
| parent::__construct( 'mon_widget', 'Mon Widget', $widget_ops ); | |
| } | |
| // Définit le contenu du widget | |
| public function widget( $args, $instance ) { | |
| // Définit le contenu à afficher | |
| echo $args['before_widget']; | |
| echo '<h2>'.get_bloginfo( 'name' ).'</h2>'; | |
| echo $args['after_widget']; | |
| } | |
| // Définit les options du widget | |
| public function form( $instance ) { | |
| // Pas de paramètres | |
| } | |
| } | |
| // Enregistre le widget | |
| function register_mon_widget() { | |
| register_widget( 'Mon_Widget' ); | |
| } | |
| add_action( 'widgets_init', 'register_mon_widget' ); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment