Example #1
0
function wpresponder_install()
{
    global $wpdb;
    global $db_checker;
    $WPR_PLUGIN_DIR = $GLOBALS['WPR_PLUGIN_DIR'];
    //add new capacity
    $role = get_role('administrator');
    $role->add_cap('manage_newsletters');
    //1. set up the necessary database tables
    $db_checker->perform_check();
    //2. set wpr_last_post_date to the last post published prior to this activation.
    delete_option("wpr_last_post_date");
    $args = array('orderby' => 'date', 'order' => 'DESC', 'numberposts' => 1, 'post_type' => 'post');
    $posts = get_posts($args);
    if (count($posts) > 0) {
        $post = $posts[0];
        $last_post_date = $post->post_date_gmt;
    } else {
        $last_post_date = date("Y-m-d H:i:s", time());
    }
    add_option("wpr_last_post_date", $last_post_date);
    //the confirm email, confirmation email and confirmed subject templates.
    $confirm_subject = file_get_contents($WPR_PLUGIN_DIR . "/templates/confirm_subject.txt");
    $confirm_body = file_get_contents($WPR_PLUGIN_DIR . '/templates/confirm_body.txt');
    $confirmed_subject = file_get_contents($WPR_PLUGIN_DIR . "/templates/confirmed_subject.txt");
    $confirmed_body = file_get_contents($WPR_PLUGIN_DIR . "/templates/confirmed_body.txt");
    if (!get_option("wpr_confirm_subject")) {
        add_option("wpr_confirm_subject", $confirm_subject);
    } else {
        update_option("wpr_confirm_subject", $confirm_subject);
    }
    if (!get_option("wpr_confirm_body")) {
        add_option("wpr_confirm_body", $confirm_body);
    } else {
        update_option("wpr_confirm_body", $confirm_body);
    }
    if (!get_option("wpr_confirmed_subject")) {
        add_option("wpr_confirmed_subject", $confirmed_subject);
    } else {
        update_option("wpr_confirmed_subject", $confirmed_subject);
    }
    if (!get_option("wpr_confirmed_body")) {
        add_option("wpr_confirmed_body", $confirmed_body);
    } else {
        update_option("wpr_confirmed_body", $confirmed_body);
    }
    //the cron variable.
    if (!get_option("wpr_next_cron")) {
        add_option("wpr_next_cron", time() + 300);
    }
    //initialize options
    _wpr_initialize_options();
    createNotificationEmail();
    wpr_enable_tutorial();
    wpr_enable_updates();
    _wpr_schedule_crons_initial();
}
Example #2
0
function _wpr_settings_post_handler()
{
    if (check_admin_referer("_wpr_settings")) {
        update_option("wpr_address", $_POST['address']);
        update_option("wpr_hourlylimit", $_POST['hourly']);
        delete_option("wpr_smtpenabled");
        add_option("wpr_smtpenabled", isset($_POST['enablesmtp']) ? 1 : 0);
        do_action("_wpr_settings_form_post");
        delete_option("wpr_smtphostname");
        add_option("wpr_smtphostname", $_POST['smtphostname']);
        delete_option("wpr_smtpport");
        add_option("wpr_smtpport", $_POST['smtpport']);
        delete_option("wpr_smtprequireauth");
        add_option("wpr_smtprequireauth", $_POST['smtprequireauth'] == 1 ? 1 : 0);
        delete_option("wpr_smtpusername");
        add_option("wpr_smtpusername", $_POST['smtpusername']);
        delete_option("wpr_smtppassword");
        add_option("wpr_smtppassword", $_POST['smtppassword']);
        delete_option("wpr_smtpsecure");
        if ($_POST['securesmtp'] != 'ssl') {
            $securesmtp = $_POST['securesmtp'] == 'tls' ? "tls" : "none";
        } else {
            $securesmtp = "ssl";
        }
        add_option("wpr_smtpsecure", $securesmtp);
        //notification settings
        $currentNotificationValue = get_option("wpr_notification_custom_email");
        switch ($_POST['notification_email']) {
            case 'customemail':
                $theNotificationEmail = $_POST['notification_custom_email'];
                delete_option('wpr_notification_custom_email');
                add_option('wpr_notification_custom_email', $theNotificationEmail);
                break;
            case 'adminemail':
                delete_option('wpr_notification_custom_email');
                add_option('wpr_notification_custom_email', 'admin_email');
                break;
        }
        if ($_POST['tutorialenable'] == 'enabled' && get_option('wpr_tutorial_active') == 'off') {
            wpr_enable_tutorial();
        } else {
            if ($_POST['tutorialenable'] == 'disabled' && get_option('wpr_tutorial_active') == 'on') {
                wpr_disable_tutorial();
            }
        }
        if ($_POST['updatesenable'] == 'enabled' && get_option('wpr_updates_active') == 'off') {
            wpr_enable_updates();
        } else {
            if ($_POST['updatesenable'] == 'disabled' && get_option('wpr_updates_active') == 'on') {
                wpr_disable_updates();
            }
        }
        $settings_url = _wpr_admin_url("settings");
        wp_redirect($settings_url);
        exit;
    }
}
Example #3
0
 public function install()
 {
     $this->manageCapabilities();
     $this->manageDatabaseStructure();
     $this->updateLastPostDate();
     $this->loadEmailTemplates();
     $this->setNextCronScheduleTime();
     $this->initializeOptions();
     $this->updateNotificationEmail();
     wpr_enable_tutorial();
     wpr_enable_updates();
     _wpr_schedule_crons_initial();
 }