Skip to content

Instantly share code, notes, and snippets.

@TomFrearson
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomFrearson/9722301 to your computer and use it in GitHub Desktop.
Save TomFrearson/9722301 to your computer and use it in GitHub Desktop.
Code to insert AWeber signup form into WooThemes' Subscribe and Connect feature from an external file. Code checks that neither the Feedburner or MailChimp URL's have been set before inserting the AWeber form.
<?php
/*-----------------------------------------------------------------------------------*/
/* Subscribe / Connect */
/*-----------------------------------------------------------------------------------*/
if (!function_exists('woo_subscribe_connect')) {
function woo_subscribe_connect($widget = 'false', $title = '', $form = '', $social = '') {
//Setup default variables, overriding them if the "Theme Options" have been saved.
$settings = array(
'connect' => 'false',
'connect_title' => __('Subscribe' , 'woothemes'),
'connect_related' => 'true',
'connect_content' => __( 'Subscribe to our e-mail newsletter to receive updates.', 'woothemes' ),
'connect_newsletter_id' => '',
'connect_mailchimp_list_url' => '',
'feed_url' => '',
'connect_rss' => '',
'connect_twitter' => '',
'connect_facebook' => '',
'connect_youtube' => '',
'connect_flickr' => '',
'connect_linkedin' => '',
'connect_delicious' => '',
'connect_rss' => '',
'connect_googleplus' => '',
'connect_dribbble' => '',
'connect_instagram' => '',
'connect_vimeo' => '',
'connect_pinterest' => ''
);
$settings = woo_get_dynamic_values( $settings );
// Get language for form
$locale = get_locale();
if ( '' == $locale )
$locale = 'en_US';
// Setup title
if ( $widget != 'true' )
$title = $settings[ 'connect_title' ];
// Setup related post (not in widget)
$related_posts = '';
if ( $settings[ 'connect_related' ] == "true" AND $widget != "true" )
$related_posts = do_shortcode( '[related_posts limit="5"]' );
?>
<?php if ( $settings[ 'connect' ] == "true" OR $widget == 'true' ) : ?>
<aside id="connect">
<h3><?php if ( $title ) echo stripslashes( $title ); else _e('Subscribe','woothemes'); ?></h3>
<div <?php if ( $related_posts != '' ) echo 'class="col-left"'; ?>>
<p><?php if ( $settings['connect_content'] != '') echo stripslashes( $settings['connect_content'] ); else _e('Subscribe to our e-mail newsletter to receive updates.', 'woothemes'); ?></p>
<?php if ( $settings['connect_newsletter_id'] != "" AND $form != 'on' ) : ?>
<form class="newsletter-form<?php if ( $related_posts == '' ) echo ' fl'; ?>" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=<?php echo $settings['connect_newsletter_id']; ?>', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">
<input class="email" type="text" name="email" value="<?php _e('E-mail','woothemes'); ?>" onfocus="if (this.value == '<?php _e('E-mail','woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('E-mail','woothemes'); ?>';}" />
<input type="hidden" value="<?php echo $settings['connect_newsletter_id']; ?>" name="uri"/>
<input type="hidden" value="<?php echo esc_attr( get_bloginfo('name') ); ?>" name="title"/>
<input type="hidden" name="loc" value="<?php echo $locale; ?>"/>
<input class="submit button" type="submit" name="submit" value="<?php _e('Submit', 'woothemes'); ?>" />
</form>
<?php endif; ?>
<?php if ( $settings['connect_mailchimp_list_url'] != "" AND $form != 'on' AND $settings['connect_newsletter_id'] == "" ) : ?>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form class="newsletter-form<?php if ( $related_posts == '' ) echo ' fl'; ?>" action="<?php echo $settings['connect_mailchimp_list_url']; ?>" method="post" target="popupwindow" onsubmit="window.open('<?php echo $settings['connect_mailchimp_list_url']; ?>', 'popupwindow', 'scrollbars=yes,width=650,height=520');return true">
<input type="text" name="EMAIL" class="required email" value="<?php _e('E-mail','woothemes'); ?>" id="mce-EMAIL" onfocus="if (this.value == '<?php _e('E-mail','woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('E-mail','woothemes'); ?>';}">
<input type="submit" value="<?php _e('Submit', 'woothemes'); ?>" name="subscribe" id="mc-embedded-subscribe" class="btn submit button">
</form>
</div>
<!--End mc_embed_signup-->
<?php endif; ?>
<?php if ( $settings['connect_mailchimp_list_url'] == "" AND $form != 'on' AND $settings['connect_newsletter_id'] == "" ) : ?>
<!--Begin AWeber Signup Form-->
<div id="mc_embed_signup">
<?php include_once( get_stylesheet_directory() . '/aweber-form.php' ); ?>
</div>
<!--End mc_embed_signup-->
<?php endif; ?>
<?php if ( $social != 'on' ) : ?>
<div class="social<?php if ( $related_posts == '' AND $settings['connect_newsletter_id' ] != "" ) echo ' fr'; ?>">
<?php if ( $settings['connect_rss' ] == "true" ) { ?>
<a href="<?php if ( $settings['feed_url'] ) { echo esc_url( $settings['feed_url'] ); } else { echo get_bloginfo_rss('rss2_url'); } ?>" class="subscribe" title="RSS"></a>
<?php } if ( $settings['connect_twitter' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_twitter'] ); ?>" class="twitter" title="Twitter"></a>
<?php } if ( $settings['connect_facebook' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_facebook'] ); ?>" class="facebook" title="Facebook"></a>
<?php } if ( $settings['connect_youtube' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_youtube'] ); ?>" class="youtube" title="YouTube"></a>
<?php } if ( $settings['connect_flickr' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_flickr'] ); ?>" class="flickr" title="Flickr"></a>
<?php } if ( $settings['connect_linkedin' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_linkedin'] ); ?>" class="linkedin" title="LinkedIn"></a>
<?php } if ( $settings['connect_delicious' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_delicious'] ); ?>" class="delicious" title="Delicious"></a>
<?php } if ( $settings['connect_googleplus' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_googleplus'] ); ?>" class="googleplus" title="Google+"></a>
<?php } if ( $settings['connect_dribbble' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_dribbble'] ); ?>" class="dribbble" title="Dribbble"></a>
<?php } if ( $settings['connect_instagram' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_instagram'] ); ?>" class="instagram" title="Instagram"></a>
<?php } if ( $settings['connect_vimeo' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_vimeo'] ); ?>" class="vimeo" title="Vimeo"></a>
<?php } if ( $settings['connect_pinterest' ] != "" ) { ?>
<a target="_blank" href="<?php echo esc_url( $settings['connect_pinterest'] ); ?>" class="pinterest" title="Pinterest"></a>
<?php } ?>
</div>
<?php endif; ?>
</div><!-- col-left -->
<?php if ( $settings['connect_related'] == "true" AND $related_posts != '' ) : ?>
<div class="related-posts col-right">
<h4><?php _e('Related Posts:', 'woothemes'); ?></h4>
<?php echo $related_posts; ?>
</div><!-- col-right -->
<?php wp_reset_query(); endif; ?>
<div class="fix"></div>
</aside>
<?php endif; ?>
<?php
}
}
?>
@TomFrearson
Copy link
Author

Lines 76-82 is the code I've added to the original function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment