-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDotmailerNewsletterWidget.php
60 lines (49 loc) · 1.81 KB
/
DotmailerNewsletterWidget.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
55
56
57
58
59
60
<?php
class DotmailerNewsletterWidget extends WP_Widget {
public function __construct()
{
parent::WP_Widget(false, $name = __('dotmailer Newsletter Widget', 'DotmailerNewsletterWidget') );
}
public function form( $instance )
{
if ( $instance ) {
$title = esc_attr($instance['title']);
} else {
$title = '';
}
echo '<p>Title:
<input class="widefat" id="' . $this->get_field_id("title") . '" name="' . $this->get_field_name("title") . '" type="text" value="' . $title . '" />
</p>';
}
public function update( $new_instance, $old_instance )
{
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
public function widget( $args, $instance )
{
extract ( $args );
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
echo '<div class="widget-text wp_widget_plugin_box">';
if ( $title ) {
echo $before_title . $title . $after_title;
}
$options = get_option( 'dotmailer_option_name' );
$username = $options['dotmailer_username'];
$password = $options['dotmailer_password'];
?>
<form name="dotmailer-subscribe" id="dotmailer-subscribe" method="post" action="<?php echo get_site_url() ?>/wp-content/plugins/dotmailer-newsletter/DotmailerNewsletterSubscribe.php">
<input class="dotmailer-email" type="email" name="dotmailer-email" id="dotmailer-email" />
<button type="submit">Subscribe</button>
</form>
<p id="form-messages"></p>
<?php
echo '</div>';
echo $after_widget;
}
}
$script = get_site_url() . '/wp-content/plugins/dotmailer-newsletter/js/dotmailerAjax.js';
wp_enqueue_script('dotmailer AJAX', $script, array('jquery'));
add_action('widgets_init', create_function('', 'return register_widget("DotmailerNewsletterWidget");') );