Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
firepot
/
wp-content
/
plugins
/
cyarb-toolkit
/
inc
:
cyarb-newsletter.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php /** * Newsletter Widget */ class Cyarb_newsletter_info extends WP_Widget{ function __construct(){ $widget_ops = array('description' => esc_html__('Display Newsletter Info', 'cyarb-toolkit')); parent::__construct( false, esc_html__('Cyarb Footer Newsletter', 'cyarb-toolkit'), $widget_ops); } function widget($args, $instance){ extract($args); global $cyarb_theme; $title = apply_filters('widget_title', $instance['title']); echo wp_kses_post($before_widget); ?> <h3><?php echo esc_html($instance['title']); ?></h3> <div class="newsletter-box"> <?php if( $instance['newsletter_info'] != '' ): ?> <p><?php echo esc_html($instance['newsletter_info']); ?></p> <?php endif; ?> <?php if( $instance['placeholder_text'] != '' ): ?> <form class="mailchimp newsletter-form" method="post"> <div class="form-group"> <input type="email" class="input-newsletter" placeholder="<?php echo esc_html($instance['placeholder_text']); ?>" name="EMAIL" required autocomplete="off"> <button type="submit"><?php echo esc_html($instance['button_text']); ?> <i class="lni lni-plane"></i></button> </div> <p class="mchimp-errmessage" style="display: none;"></p> <p class="mchimp-sucmessage" style="display: none;"></p> </form> <?php endif; ?> </div> <script> ;(function($){ "use strict"; $(document).ready(function () { // MAILCHIMP $(".mailchimp").ajaxChimp({ callback: mailchimpCallback, url: "<?php echo esc_js($instance['email_url']) ?>" }); $(".memail").on("focus", function () { $(".mchimp-errmessage").fadeOut(); $(".mchimp-sucmessage").fadeOut(); }); $(".memail").on("keydown", function () { $(".mchimp-errmessage").fadeOut(); $(".mchimp-sucmessage").fadeOut(); }); $(".memail").on("click", function () { $(".memail").val(""); }); function mailchimpCallback(resp) { if (resp.result === "success") { $(".mchimp-sucmessage").html(resp.msg).fadeIn(1000); $(".mchimp-sucmessage").fadeOut(3000); } else if (resp.result === "error") { $(".mchimp-errmessage").html(resp.msg).fadeIn(1000); } } }); })(jQuery) </script> <?php echo wp_kses_post($after_widget); } function update($new_instance, $old_instance){ $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['newsletter_info'] = $new_instance['newsletter_info']; $instance['placeholder_text'] = $new_instance['placeholder_text']; $instance['button_text'] = $new_instance['button_text']; $instance['email_url'] = $new_instance['email_url']; return $instance; } function form($instance){ $defaults = array( 'title' => esc_html__('Newsletter', 'cyarb-toolkit'), 'newsletter_info' => esc_html__('Latest resources sent to your inbox weekly'), 'placeholder_text' => esc_html__('Enter your email address'), 'button_text' => esc_html__('Subscribe Now'), 'email_url' => 'https://envytheme.us20.list-manage.com/subscribe/post?u=60e1ffe2e8a68ce1204cd39a5&id=42d6d188d9', ); $instance = wp_parse_args((array)$instance, $defaults); ?> <p> <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"> <?php esc_html_e('Title:', 'cyarb-toolkit'); ?> <input class="widget" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo wp_kses_post($instance['title']); ?>" /> </label> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('newsletter_info')); ?>"> <?php esc_html_e('Newsletter Info:', 'cyarb-toolkit'); ?> <input class="widget" id="<?php echo esc_attr($this->get_field_id('newsletter_info')); ?>" name="<?php echo esc_attr($this->get_field_name('newsletter_info')); ?>" type="text" value="<?php echo wp_kses_post($instance['newsletter_info']); ?>" /> </label> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('placeholder_text')); ?>"> <?php esc_html_e('Placeholder Text:', 'cyarb-toolkit'); ?> <input class="widget" id="<?php echo esc_attr($this->get_field_id('placeholder_text')); ?>" name="<?php echo esc_attr($this->get_field_name('placeholder_text')); ?>" type="text" value="<?php echo wp_kses_post($instance['placeholder_text']); ?>" /> </label> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('button_text')); ?>"> <?php esc_html_e('Button Text:', 'cyarb-toolkit'); ?> <input class="widget" id="<?php echo esc_attr($this->get_field_id('button_text')); ?>" name="<?php echo esc_attr($this->get_field_name('button_text')); ?>" type="text" value="<?php echo wp_kses_post($instance['button_text']); ?>" /> </label> </p> <p> <label for="<?php echo $this->get_field_id('email_url'); ?>"> <?php esc_html_e('Action URL:', 'cyarb-toolkit'); ?> <input class="widefat" id="<?php echo $this->get_field_id('email_url'); ?>" name="<?php echo $this->get_field_name('email_url'); ?>" type="text" value="<?php echo $instance['email_url']; ?>" /> </label> <i>Enter here your MailChimp action URL. <a href="https://docs.envytheme.com/docs/cyarb-theme-documentation/tips-guides-troubleshoots/get-mailchimp-newsletter-form-action-url/" target="_blank"> How to </a></i> </p> <?php } } function cyarb_register_newsletter_info() { register_widget('Cyarb_newsletter_info'); } add_action('widgets_init', 'cyarb_register_newsletter_info');