74 lines
2.3 KiB
PHP
74 lines
2.3 KiB
PHP
<?php
|
|
|
|
class Float_Widget_Newsletter extends WP_Widget {
|
|
public function __construct() {
|
|
parent::__construct (
|
|
'float_widget-newsletter',
|
|
'Float Newsletter',
|
|
|
|
array(
|
|
'description' => 'newsletter'
|
|
)
|
|
);
|
|
}
|
|
|
|
public function widget( $args, $instance ) {
|
|
$title = apply_filters( 'widget_title', $instance['title'] );
|
|
echo $args['before_widget'];
|
|
|
|
if ( $title ) {
|
|
echo $args['before_title'] . $title . $args['after_title'];
|
|
}
|
|
?>
|
|
|
|
<div class="card border-0 subcribe-form-section bg-transparent m-0 p-0">
|
|
<div class="card-body subcribe-form-section__body">
|
|
<form class="subscribe-form justify-content-start flex-column widget" method="POST" data-action="/newsletter-subscribe">
|
|
<div class="form-group">
|
|
<input type='text' class="form-control" name="name" placeholder="name" required />
|
|
</div>
|
|
|
|
<div class="form-group ml-0">
|
|
<input type='email' class="form-control" name="email" placeholder="email" required />
|
|
</div>
|
|
<div class="form-msg-block"></div>
|
|
</form>
|
|
<button type="button" class="btn subcribe-button">Sign-up</button>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
echo $args['after_widget'];
|
|
}
|
|
|
|
public function update( $new_instance, $old_instance ) {
|
|
parent::update( $new_instance, $old_instance );
|
|
|
|
$instance = $old_instance;
|
|
$instance['title'] = strip_tags($new_instance['title']);
|
|
return $instance;
|
|
}
|
|
|
|
public function form( $instance ) {
|
|
parent::form( $instance );
|
|
|
|
$default = array(
|
|
'title' => 'Sign-up for Float'
|
|
);
|
|
|
|
$instance = wp_parse_args( (array) $instance, $default);
|
|
|
|
$title = esc_attr( $instance['title'] );
|
|
|
|
echo 'Title <input class="widefat" type="text" name="' . $this->get_field_name('title') . '" value="' . $title . '" />';
|
|
}
|
|
}
|
|
|
|
// Register the widget
|
|
function float_widget_newsletter_function() {
|
|
register_widget( 'Float_Widget_Newsletter' );
|
|
}
|
|
add_action( 'widgets_init', 'float_widget_newsletter_function' );
|
|
|
|
?>
|