admin_url( 'admin-ajax.php' ), 'subscribeNonce' => wp_create_nonce('subscribe-nonce'), 'enabled' => $enabled, 'animation' => $apData['animation_type'] ? $apData['animation_type'] : 'tornado', 'popup_or_embed' => $apData['popup_or_embed'], 'widget_id' => $apData['widget_id'] ) ); } add_action('wp_enqueue_scripts', 'popup_script', 12); // priority 12 function admin_scripts() { wp_enqueue_style( 'ap-embed', plugin_dir_url( __FILE__ ) . 'css/animated-popup-embed.css'); wp_enqueue_style( 'ap-admin', plugin_dir_url( __FILE__ ) . 'css/animated-popup-admin.css'); wp_enqueue_script( 'timelinemax', plugin_dir_url( __FILE__ ) . 'js/TimelineMax.min.js', array() ); wp_enqueue_script( 'tweenlite', plugin_dir_url( __FILE__ ) . 'js/TweenLite.min.js', array() ); wp_enqueue_script( 'easepack', plugin_dir_url( __FILE__ ) . 'js/EasePack.min.js', array() ); wp_enqueue_script( 'cssplugin', plugin_dir_url( __FILE__ ) . 'js/CSSPlugin.min.js', array() ); wp_enqueue_script( 'ap-elements', plugin_dir_url( __FILE__ ) . 'js/elements.js', array( 'jquery' ) ); wp_enqueue_script( 'ap-admin', plugin_dir_url( __FILE__ ) . 'js/ap-admin.js', array('jquery') ); wp_enqueue_script( 'ap-animation', plugin_dir_url( __FILE__ ) . 'js/animation.js', array( 'jquery', 'ap-elements' ) ); } add_action('admin_enqueue_scripts', 'admin_scripts'); // create settings link on plugins page add_filter( 'plugin_row_meta', 'ap_row_meta', 10, 2 ); function ap_row_meta( $links, $file ) { if ( strpos( $file, 'animated-popup.php' ) !== false ) { $settings_page = admin_url() . 'admin.php?page=animated-popup-menu'; $new_links = array( 'Settings' ); $links = array_merge( $links, $new_links ); } return $links; } // Add Shortcode function popup_shortcode( $atts ) { // Attributes extract( shortcode_atts( array( ), $atts ) ); $apData = get_site_option('animated_popup_data'); if (!$apData) { require_once('animated-popup-data-init.php'); update_site_option('animated_popup_data', $apData); } if (is_front_page() && $apData['popup_or_embed'] === 'popup') { require_once 'animated-popup-popup.php'; return $templateString; } else if ($apData['popup_or_embed'] === 'embed') { require_once 'animated-popup-embed.php'; return $templateString; } } add_shortcode( 'animated_popup', 'popup_shortcode' ); class Popup_Widget extends WP_Widget { function __construct() { parent::__construct( 'popup_widget', // Base ID __( 'Animated Popup', 'text_domain' ), // Name // array( 'description' => __( 'Add an Animated Popup', 'text_domain' ), ) // Args array() ); } // * Front-end display of widget. public function widget( $args, $instance ) { $apData = get_site_option('animated_popup_data'); if (!$apData) { require_once('animated-popup-data-init.php'); } $apData['widget_id'] = $args['widget_id']; update_site_option('animated_popup_data', $apData); echo $args['before_widget']; echo $args['before_title']; echo $args['after_title']; if (is_front_page() && $apData['popup_or_embed'] === 'popup') { require_once 'animated-popup-popup.php'; echo $templateString; } else if ($apData['popup_or_embed'] === 'embed') { require_once 'animated-popup-embed.php'; echo $templateString; } echo $args['after_widget']; } // * Back-end widget form. public function form( $instance ) { } // * Sanitize widget form values as they are saved. public function update( $new_instance, $old_instance ) { $instance = array(); // select menu return $instance; } } // class popup_Widget // Register and load the widget function popup_load_widget() { register_widget( 'Popup_Widget' ); } add_action( 'widgets_init', 'popup_load_widget' ); /* ADMINISTRATION PAGE */ register_activation_hook(__FILE__, function () { // doesn't run for mu-plugins }); register_deactivation_hook( __FILE__, function () { // doesn't run for mu-plugins delete_site_option('animated_popup_data'); }); add_action( 'admin_menu', 'animated_popup_register_admin', 5); add_action( 'network_admin_menu', 'animated_popup_register_network_admin' ); function animated_popup_register_admin() { add_menu_page('Animated Popup Options', 'Animated Popup', 'manage_options', 'animated-popup-menu', 'animated_popup_admin', '', '99.23434542'); } function animated_popup_register_network_admin() { add_menu_page('Animated Popup Options', 'Animated Popup', 'delete_users', 'animated-popup-menu', 'animated_popup_admin', ''); } function animated_popup_admin() { // one form has all inputs data // jquery below controls disabled inputs // admin update button submits data via php and redirects to same page with $_POST data // front-end html is in template file // styles for the html are in a template to load in front and back // animation is also in a file to be loaded in front and back // jquery/greensock external script (subscribe.js) triggers ajax // ajax script to subscribe the person to the list(s) $errors = array(); $apData = get_site_option('animated_popup_data'); if (!$apData) { require_once('animated-popup-data-init.php'); update_site_option('animated_popup_data', $apData); } // check if button was pushed // for data to persist, it must be added to $apData and saved with updateOption(..., 'advanced_popup_data', ...) if (isset($_POST['Submit'])) { // clear checkboxes $apData['wpmail_enabled'] = false; // $apData['mandrill_enabled'] = false; $apData['mailchimp_enabled'] = false; $apData['mailchimp_double_optin'] = false; $apData['mailchimp_welcome'] = false; $apData['aweber_enabled'] = false; $apData['mailgun_enabled'] = false; $apData['madmimi_enabled'] = false; // update all options (sanitize first) foreach ($_POST as $k => $v) { if ($k !== 'Submit' && $k !== '_wpnonce' && $k !== '_wp_http_referer' && trim($v)) { $apData[$k] = strip_tags($v); } } update_site_option('animated_popup_data', $apData); } // ADMIN ERRORS $errors['Mailchimp'] = $apData['mailchimp_error']; $errors['AWeber'] = $apData['aweber_error']; $errors['Mailgun'] = $apData['mailgun_error']; $errors['Mad Mimi'] = $apData['madmimi_error']; foreach ($errors as $k => $e) { if ($e) { ?>
Error:

Animated Popup Settings

Use the shortcode or widget to embed your popup somewhere on your site!

Shortcode example: [animated_popup]

Box

Header Text:
Paragraph Text:
Box Color
Button Color
Animation Type
Window Type

WP Mail

Have an email sent to your Admin Email Address whenever someone signs up with Animated Popup!

For some hosts, Gmail and Yahoo Mail don't work due to strict security requirements. If that's the case with your host, we recommend you use an email address that uses your domain.

You can always forward those emails over to your Gmail/Yahoo account if you want. For more information, refer to this page FAQ Troubleshooting E-mails.

Enable WP Mail:
/>




Premium Features - add people to mailing lists effortlessly!

MailChimp

Enable Mailchimp:
Your Mailchimp API Key:
Your Mailchimp List ID:
Double Opt-In:
/>
Welcome Email:
/>

AWeber

Enable Aweber:
Your AWeber List Name:

Mailgun

Enable Mailgun:
Your Mailgun API Key:
Your Mailgun List Address:

Mad Mimi

Enable Mad Mimi:
Your Mad Mimi Username/Email:
Your Mad Mimi API Key:
Your Mad Mimi List Name:
'', 'enabled' => array(), 'validation' => false)); exit; } // WP_MAIL // if ($apData['wpmail_enabled'] === 'on') { $enabled[] = 'wpmail'; $eHeaders = array(); $eHeaders[] = 'From: Animated Popup <' . get_site_option('admin_email') . ">\r\n"; $eHeaders[] = 'Content-Type: text/html; charset=UTF-8'; $eSubject = 'Animated Popup - A New Subscriber!'; $eMessage = ''; $eMessage .= '

Animated Popup

This new guy has signed up to get updates from you:

'; $eMessage .= $email; $eMessage .= '

Wait! Don\'t waste time adding this subscriber to your mailing list manually!

Have them added the moment they click the subscribe button!

Supported providers: Mailchimp, AWeber, Mailgun, Mad Mimi

Get the Pro version to use this feature now!

'; wp_mail( get_site_option('admin_email'), $eSubject, $eMessage, $eHeaders ); } // MANDRILL // update_site_option('animated_popup_data', $apData); // add any errors echo json_encode(array('message' => $message, 'enabled' => $enabled, 'validation' => true)); exit; }