static function send_instant_notification($data)
 {
     $options = SendPress_Option::get('notification_options');
     if ($options['notifications-enable']) {
         $subscribed = '';
         $unsubscribed = '';
         if (intval($options['subscribed']) === 0) {
             //build instant subscribed
             $subscribed = SendPress_Notifications_Manager::build_subscribed_notification($data);
         }
         if (intval($options['unsubscribed']) === 0) {
             //build instant subscribed
             $unsubscribed = SendPress_Notifications_Manager::build_unsibscribed_notification($data);
         }
         if (strlen($subscribed) === 0 && strlen($unsubscribed) === 0) {
             return;
         }
         $body = $subscribed . "<br><br>" . $unsubscribed;
         $text = $subscribed . $unsubscribed;
         SendPress_Notifications_Manager::send_notification($body, $text);
     }
 }
 static function add_subscribe_event($sid, $lid, $type)
 {
     global $wpdb;
     /*
     $event_type = 'unknown_event_type';
     if( is_numeric($type) ){
     
     	if($type == 2){
     		$event_type = 'subscribed';
     	}elseif($type == 3){
     		$event_type = 'unsubscribed';
     	}elseif($type==4){
     		$event_type = 'bounce';
     	}elseif($type==1){
     		$event_type = 'optin';
     	}
     }
     
     $event_data = array(
     	'eventdate'=>SendPress_Data::gmdate(),
     	'subscriberID' => $sid,
     	'listID'=>$lid,
     	'type'=>$event_type
     );
     
     $wpdb->insert( SendPress_Data::subscriber_event_table(),  $event_data);
     */
     //if instant, check if we need a notification and send one
     SendPress_Notifications_Manager::send_instant_notification($event_data);
 }
 function init()
 {
     //add_action('register_form',array( $this , 'add_registration_fields'));
     SendPress_Ajax_Loader::init();
     //SendPress_Signup_Shortcode::init();
     SendPress_Sender::init();
     SendPress_Cron::get_instance();
     SendPress_Videos::init();
     sendpress_register_sender('SendPress_Sender_Website');
     sendpress_register_sender('SendPress_Sender_Gmail');
     add_action('sendpress_event', array('SendPress_Tracking', 'event'), 1, 1);
     do_action('sendpress_init');
     SendPress_Admin::add_cap('Emails_Send', 'sendpress_email_send');
     $indexer = "";
     $permalinks = get_option('permalink_structure');
     if ($permalinks) {
         $pos = strpos($permalinks, "index.php");
         if ($pos > 0) {
             // note: three equal signs
             $indexer = "index.php/";
         }
     }
     add_rewrite_rule("^{$indexer}sendpress/([^/]+)/?", 'index.php?sendpress=$matches[1]', "top");
     if (defined('WP_ADMIN') && WP_ADMIN == true) {
         $sendpress_screen_options = new SendPress_Screen_Options();
     }
     $this->add_custom_post();
     //add_filter( 'cron_schedules', array($this,'cron_schedule' ));
     //add_action( 'wp_loaded', array( $this, 'add_cron' ) );
     if (is_admin()) {
         SendPress_Pro_Manager::init();
         SendPress_Tracking::init();
         SendPress_Notifications_Manager::init();
         if (isset($_GET['spv'])) {
             SendPress_Option::set('version', $_GET['spv']);
         }
         if (isset($_GET['sp-admin-code']) && current_user_can('manage_options')) {
             switch ($_GET['sp-admin-code']) {
                 case 'install-tables':
                     $this->install_tables();
                     break;
                 case 'remove-key':
                     SendPress_Option::set('api_key', '');
                     SendPress_Pro_Manager::set_pro_state(false);
                     //this will delete the transient
                     break;
                 default:
                     # code...
                     break;
             }
         }
         $this->ready_for_sending();
         add_action('admin_menu', array($this, 'admin_menu'));
         add_action('admin_init', array($this, 'admin_init'));
         add_action('admin_notices', array($this, 'admin_notice'));
         add_action('admin_print_scripts', array($this, 'editor_insidepopup'));
         add_filter('gettext', array($this, 'change_button_text'), null, 2);
         add_action('sendpress_notices', array($this, 'sendpress_notices'));
         add_filter('user_has_cap', array($this, 'user_has_cap'), 10, 3);
         //SendPress_Option::set('default-signup-widget-settings',false);
     } else {
         if (SendPress_Option::get('sp_widget_shortdoces')) {
             add_filter('widget_text', 'do_shortcode');
         }
     }
     add_image_size('sendpress-max', 600, 600);
     add_filter('template_include', array($this, 'template_include'), 5);
     add_action('sendpress_cron_action', array($this, 'sendpress_cron_action_run'));
     //using this for now, might find a different way to include things later
     // global $load_signup_js;
     // $load_signup_js = false;
     add_action('wp_enqueue_scripts', array($this, 'add_front_end_scripts'));
     add_action('wp_enqueue_scripts', array($this, 'add_front_end_styles'));
     add_action('wp_head', array($this, 'handle_front_end_posts'));
 }