static function &init()
 {
     static $instance = false;
     if (!$instance) {
         $instance = new SendPress_Ajax_Loader();
         $instance->add_hooks();
     }
     return $instance;
 }
 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'));
 }