-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcc-newsletter-form.php
54 lines (49 loc) · 3.1 KB
/
cc-newsletter-form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
class WP_Widget_Newsletter_Form extends WP_Widget {
function __construct() {
$widget_ops = array(
'classname' => 'newsletter-form',
'description' => 'Display the newsletter form',
);
$control_ops = array();
parent::__construct( 'newsletter-form', 'CC Newsletter form', $widget_ops, $control_ops );
}
function widget( $args, $instance ) {
$button_text = ( ! empty( $instance['button_text'] ) ) ? esc_attr( $instance['button_text'] ) : 'Join';
$placeholder = ( ! empty( $instance['placeholder'] ) ) ? esc_attr( $instance['placeholder'] ) : 'Enter your email';
$has_border = ( $instance['has_border'] ) ? ' has-border' : '';
echo '<div class="widget newsletter' . $has_border . '">';
if ( ! empty( $instance['title'] ) ) {
echo '<h4 class="b-header widget-title">' . esc_attr( $instance['title'] ) . '</h4>';
}
if ( ! empty( $instance['byline'] ) ) {
echo '<small class="widget-byline">' . esc_attr( $instance['byline'] ) . '</small>';
}
echo '<form method="post" action="https://us.e-activist.com/page/6669/data/2">';
echo '<div class="field has-addons">';
echo '<div class="control">';
echo '<input id="en__field_supporter_emailAddress" type="text" class="input" name="supporter.emailAddress" value="' . $placeholder . '" />';
echo '</div>';
echo '<div class="control">';
echo '<input type="submit" alt="Search" class="button small is-primary" value="' . $button_text . '" />';
echo '</div>';
echo '</div>';
echo '</form>';
echo '</div>';
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
function form( $instance ) {
extract( $instance );
echo '<p><label for="' . $this->get_field_id( 'title' ) . '">Title: <input type="text" name="' . $this->get_field_name( 'title' ) . '" id="' . $this->get_field_id( 'title' ) . '" value="' . $instance['title'] . '" class="widefat" /></label></p>';
echo '<p><label for="' . $this->get_field_id( 'byline' ) . '">Byline: <input type="text" name="' . $this->get_field_name( ' byline' ) . '" id="' . $this->get_field_id( ' byline' ) . '" value="' . $instance[' byline'] . '" class="widefat" /></label></p>';
echo '<p><label for="' . $this->get_field_id( 'placeholder' ) . '">Placeholder: <input type="text" name="' . $this->get_field_name( 'placeholder' ) . '" id="' . $this->get_field_id( 'placeholder' ) . '" value="' . $instance['placeholder'] . '" class="widefat" /></label></p>';
echo '<p><label for="' . $this->get_field_id( 'button_text' ) . '">Button Text: <input type="text" name="' . $this->get_field_name( 'button_text' ) . '" id="' . $this->get_field_id( 'button_text' ) . '" value="' . $instance['button_text'] . '" class="widefat" /></label></p>';
echo '<p><label for="' . $this->get_field_name( 'has_border' ) . '">Add border? </label><input type="checkbox" id="' . $this->get_field_id( 'has_border' ) . '"' . ( ( ! empty( $instance['has_border'] ) ) ? ' checked="checked" ' : '' ) . ' name="' . $this->get_field_name( 'has_border' ) . '" value="1"></p>';
}
}
function cc_newsletter_widget_init() {
register_widget( 'WP_Widget_Newsletter_Form' );
}
add_action( 'widgets_init', 'cc_newsletter_widget_init' );