I developed new module in wordpress 4.4, i created new widget then added widget title from the back-office.
EveryThing was nice, but i can't display widget form in the front office.
I used this code to display :
<?php dynamic_sidebar('ylgsubscriber');?>
my widget class is:
class ylgsubscriber_widget extends WP_Widget
{
public function __construct()
{
parent::__construct('ylgsubscriber', 'YlgSubscriberWidget',
array('description' => 'Un formulaire d\'inscription à la newsletter.'));
}
/*
* Form to diesplay in front office
* @var $args
* @var $instance
* */
public function widget($args, $instance)
{
echo $args['before_widget'];
echo $args['before_title'];
apply_filters('widget_title', $instance['title']);
echo $args['after_title'];
include('views/ylgsubscriber_front.php');
echo $args['after_widget'];
}
/*
* Admin form
* @var $instance
* */
public function form($instance)
{
$title = isset($instance['title']) ? $instance['title'] : '';
include_once('views/ylgsubscriber_admin.php');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire