Widget get response
class GetResponse_Widget extends WP_Widget {
public function __construct() {
parent::__construct(
'gr_wdg_newsletter',
__( 'Get Response Newsletter', 'segfor' ),
array(
'description' => __( 'Mostra la newsletter per Get Form', 'segfor' ),
'classname' => 'gr_wdg_newsletter',
)
);
}
public function widget( $args, $instance ) {
echo 'suka';
}
public function form( $instance ) {
// Set default values
$instance = wp_parse_args( (array) $instance, array(
'gr_wdg_gr_wdg_campaign' => '',
) );
// Retrieve an existing value from the database
$gr_wdg_gr_wdg_campaign = !empty( $instance['gr_wdg_gr_wdg_campaign'] ) ? $instance['gr_wdg_gr_wdg_campaign'] : '';
// Form fields
echo '<p>';
echo ' <label for="' . $this->get_field_id( 'gr_wdg_gr_wdg_campaign' ) . '" class="gr_wdg_gr_wdg_campaign_label">' . __( 'Seleziona Campagna', 'segfor' ) . '</label>';
echo ' <select id="' . $this->get_field_id( 'gr_wdg_gr_wdg_campaign' ) . '" name="' . $this->get_field_name( 'gr_wdg_gr_wdg_campaign' ) . '" class="widefat">';
echo ' <option value="value1" ' . selected( $gr_wdg_gr_wdg_campaign, 'value1', false ) . '> ' . __( 'Value1', 'segfor' ) . '</option>';
echo ' <option value="value2" ' . selected( $gr_wdg_gr_wdg_campaign, 'value2', false ) . '> ' . __( 'Value2', 'segfor' ) . '</option>';
echo ' </select>';
echo '</p>';
}
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['gr_wdg_gr_wdg_campaign'] = !empty( $new_instance['gr_wdg_gr_wdg_campaign'] ) ? strip_tags( $new_instance['gr_wdg_gr_wdg_campaign'] ) : '';
return $instance;
}
}
function gr_wdg_register_widgets() {
register_widget( 'GetResponse_Widget' );
}
add_action( 'widgets_init', 'gr_wdg_register_widgets' );