Created
August 3, 2015 08:56
-
-
Save phenix-factory/2cc5998d9311d19ab8ce to your computer and use it in GitHub Desktop.
Wordpress: Widget mailchimp simple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class vertige_mailchimp extends WP_Widget { | |
/** | |
* Sets up the widgets name etc | |
*/ | |
public function __construct() { | |
parent::__construct( | |
'vertige_mailchimp', // Base ID | |
'Mailchimp', // Name | |
array( 'description' => 'Widget Mailchimp' ) // Args | |
); | |
} | |
/** | |
* Outputs the content of the widget | |
* | |
* @param array $args | |
* @param array $instance | |
*/ | |
public function widget( $args, $instance ) { | |
echo $args['before_widget']; | |
if ( ! empty( $instance['title'] ) ) { | |
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; | |
} | |
?> | |
<!-- Begin MailChimp Signup Form --> | |
<div id="mc_embed_signup"> | |
<form action="//boutiqueculturelle.us10.list-manage.com/subscribe/post?u=e0f87ecd99a372d95cb0e902b&id=ed9b32a0b1" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> | |
<div id="mc_embed_signup_scroll"> | |
<div class="mc-field-group"> | |
<label for="mce-EMAIL">Email </label> | |
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL"> | |
</div> | |
<div id="mce-responses" class="clear"> | |
<div class="response" id="mce-error-response" style="display:none"></div> | |
<div class="response" id="mce-success-response" style="display:none"></div> | |
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups--> | |
<div style="position: absolute; left: -5000px;"><input type="text" name="b_e0f87ecd99a372d95cb0e902b_ed9b32a0b1" tabindex="-1" value=""></div> | |
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div> | |
</div> | |
</form> | |
</div> | |
<!--End mc_embed_signup--> | |
<?php | |
echo $args['after_widget']; | |
} | |
/** | |
* Outputs the options form on admin | |
* | |
* @param array $instance The widget options | |
*/ | |
public function form( $instance ) { | |
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' ); | |
?> | |
<p> | |
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> | |
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> | |
</p> | |
<?php | |
} | |
/** | |
* Processing widget options on save | |
* | |
* @param array $new_instance The new options | |
* @param array $old_instance The previous options | |
*/ | |
public function update( $new_instance, $old_instance ) { | |
$instance = array(); | |
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; | |
return $instance; | |
} | |
} | |
add_action( 'widgets_init', function(){ | |
register_widget('vertige_mailchimp'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment