Aggiunto widget sidebar costellazioni

This commit is contained in:
ulaulaman 2020-10-23 22:44:30 +02:00
parent 6906205327
commit dba1213f8d
1 changed files with 53 additions and 0 deletions

View File

@ -54,4 +54,57 @@ add_action( 'widgets_init', 'register_dida' );
function register_dida() {
register_widget( 'Widget_Didattica' );
}
# costellazioni
class Widget_Stars extends WP_Widget {
/** Registrazione del widget */
public function __construct() {
parent::__construct(
'widget_stars', // Base ID
'Widget Stars', // Name
array( 'description' => __( 'Widget per l\'inserimento della sidebar delle costellazioni', 'text_domain' ), ) // Args
);
}
/** Front-end display of widget */
public function widget( $args, $instance ) {
extract( $args );
$shortcode = do_shortcode('[sbcostellazioni]');
echo $shortcode;
echo $after_widget;
}
/** Back-end widget form */
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'Titolo', 'text_domain' );
}
?>
<p>
<label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php _e( 'Titolo:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<?php
}
/** Ripulisce i valori del widget man mano che vengono salvati */
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( !empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
} // class Widget_Didattica
// Registra Widget_Didattica
add_action( 'widgets_init', 'register_stars' );
function register_stars() {
register_widget( 'Widget_Stars' );
}