Esempio n. 1
0
/**
 * Installs or upgrades the plugin.
 *
 * @since 2.2.2
 */
function wpmem_do_install()
{
    /*
     * If you need to force an install, set $chk_force = true.
     *
     * Important notes:
     *
     * 1. This will override any settings you already have for any of the plugin settings.
     * 2. This will not effect any WP settings or registered users.
     */
    $chk_force = false;
    if (!get_option('wpmembers_settings') || $chk_force == true) {
        // This is a clean install (or an upgrade from 2.1 or earlier).
        $wpmem_settings = array('version' => WPMEM_VERSION, 'block' => array('post' => is_multisite() ? 0 : 1, 'page' => 0), 'show_excerpt' => array('post' => 0, 'page' => 0), 'show_reg' => array('post' => 1, 'page' => 1), 'show_login' => array('post' => 1, 'page' => 1), 'autoex' => array('post' => array('enabled' => 0, 'length' => ''), 'page' => array('enabled' => 0, 'length' => '')), 'notify' => 0, 'mod_reg' => 0, 'captcha' => 0, 'use_exp' => 0, 'use_trial' => 0, 'warnings' => 0, 'user_pages' => array('profile' => '', 'register' => '', 'login' => ''), 'cssurl' => '', 'style' => plugin_dir_url(__FILE__) . 'css/generic-no-float.css', 'attrib' => 0, 'post_types' => array());
        // Using update_option to allow for forced update.
        update_option('wpmembers_settings', $wpmem_settings, '', 'yes');
        /*
         * Field array elements:
         * 
         * 	array(
         * 		order, 
         * 		label, 
         *		optionname, 
         * 		type, 
         * 		display, 
         * 		required, 
         * 		native, 
         * 		checked value, 
         * 		checked by default,
         * 	);
         */
        $wpmem_fields_options_arr = array(array(1, 'First Name', 'first_name', 'text', 'y', 'y', 'y'), array(2, 'Last Name', 'last_name', 'text', 'y', 'y', 'y'), array(3, 'Address 1', 'addr1', 'text', 'y', 'y', 'n'), array(4, 'Address 2', 'addr2', 'text', 'y', 'n', 'n'), array(5, 'City', 'city', 'text', 'y', 'y', 'n'), array(6, 'State', 'thestate', 'text', 'y', 'y', 'n'), array(7, 'Zip', 'zip', 'text', 'y', 'y', 'n'), array(8, 'Country', 'country', 'text', 'y', 'y', 'n'), array(9, 'Day Phone', 'phone1', 'text', 'y', 'y', 'n'), array(10, 'Email', 'user_email', 'text', 'y', 'y', 'y'), array(11, 'Confirm Email', 'confirm_email', 'text', 'n', 'n', 'n'), array(12, 'Website', 'user_url', 'text', 'n', 'n', 'y'), array(13, 'Biographical Info', 'description', 'textarea', 'n', 'n', 'y'), array(14, 'Password', 'password', 'password', 'n', 'n', 'n'), array(15, 'Confirm Password', 'confirm_password', 'password', 'n', 'n', 'n'), array(16, 'TOS', 'tos', 'checkbox', 'n', 'n', 'n', 'agree', 'n'));
        update_option('wpmembers_fields', $wpmem_fields_options_arr, '', 'yes');
        // using update_option to allow for forced update
        $wpmem_dialogs_arr = array("This content is restricted to site members.  If you are an existing user, please log in.  New users may register below.", "Sorry, that username is taken, please try another.", "Sorry, that email address already has an account.<br />Please try another.", "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.", "Your information was updated!", "Passwords did not match.<br /><br />Please try again.", "Password successfully changed!", "Either the username or email address do not exist in our records.", "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.");
        // Insert TOS dialog placeholder.
        $dummy_tos = "Put your TOS (Terms of Service) text here.  You can use HTML markup.";
        update_option('wpmembers_tos', $dummy_tos);
        update_option('wpmembers_dialogs', $wpmem_dialogs_arr, '', 'yes');
        // using update_option to allow for forced update
        wpmem_append_email();
        // If it's a new install, use the Twenty Twelve stylesheet.
        update_option('wpmembers_style', plugin_dir_url(__FILE__) . 'css/generic-no-float.css', '', 'yes');
    } else {
        wpmem_update_settings();
        wpmem_update_captcha();
        wpmem_update_dialogs();
        wpmem_append_email();
    }
}
Esempio n. 2
0
/**
 * Handles the various update actions for the default tabs
 *
 * @since 2.8
 *
 * @param string $action The action that is being done
 */
function wpmem_admin_action($action)
{
    $did_update = '';
    // makes sure $did_update is defined
    switch ($action) {
        case 'update_settings':
            include_once 'tab-options.php';
            $did_update = wpmem_update_options();
            break;
        case 'update_fields':
        case 'add_field':
        case 'edit_field':
            include_once 'tab-fields.php';
            $did_update = wpmem_update_fields($action);
            break;
        case 'update_dialogs':
            include_once 'tab-dialogs.php';
            $did_update = wpmem_update_dialogs();
            break;
        case 'update_emails':
            include_once 'tab-emails.php';
            $did_update = wpmem_update_emails();
            break;
        case 'update_captcha':
            include_once 'tab-captcha.php';
            $did_update = wpmem_update_captcha();
            break;
    }
    return $did_update;
}
/**
 * Installs or upgrades the plugin
 *
 * @since 2.2.2
 */
function wpmem_do_install()
{
    /*
    	if you need to force an install, set $chk_force = true
    	
    	IMPORTANT NOTES: 
    	
    	(1) This will override any settings you already have
    		for any of the plugin settings.  
    	
    	(2) This will not effect any WP settings or registered 
    		users.
    */
    $chk_force = false;
    if (!get_option('wpmembers_settings') || $chk_force == true) {
        // this is a clean install (or an upgrade from 2.1 or earlier)
        $wpmem_settings = array(WPMEM_VERSION, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        update_option('wpmembers_settings', $wpmem_settings, '', 'yes');
        // using update_option to allow for forced update
        // order, label, optionname, type, display, required, native, checked value, checked by default
        $wpmem_fields_options_arr = array(array(1, 'First Name', 'first_name', 'text', 'y', 'y', 'y'), array(2, 'Last Name', 'last_name', 'text', 'y', 'y', 'y'), array(3, 'Address 1', 'addr1', 'text', 'y', 'y', 'n'), array(4, 'Address 2', 'addr2', 'text', 'y', 'n', 'n'), array(5, 'City', 'city', 'text', 'y', 'y', 'n'), array(6, 'State', 'thestate', 'text', 'y', 'y', 'n'), array(7, 'Zip', 'zip', 'text', 'y', 'y', 'n'), array(8, 'Country', 'country', 'text', 'y', 'y', 'n'), array(9, 'Day Phone', 'phone1', 'text', 'y', 'y', 'n'), array(10, 'Email', 'user_email', 'text', 'y', 'y', 'y'), array(11, 'Confirm Email', 'confirm_email', 'text', 'n', 'n', 'n'), array(12, 'Website', 'user_url', 'text', 'n', 'n', 'y'), array(13, 'Biographical Info', 'description', 'textarea', 'n', 'n', 'y'), array(14, 'Password', 'password', 'password', 'n', 'n', 'n'), array(15, 'Confirm Password', 'confirm_password', 'password', 'n', 'n', 'n'), array(16, 'TOS', 'tos', 'checkbox', 'n', 'n', 'n', 'agree', 'n'));
        update_option('wpmembers_fields', $wpmem_fields_options_arr, '', 'yes');
        // using update_option to allow for forced update
        $wpmem_dialogs_arr = array("This content is restricted to site members.  If you are an existing user, please log in.  New users may register below.", "Sorry, that username is taken, please try another.", "Sorry, that email address already has an account.<br />Please try another.", "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.", "Your information was updated!", "Passwords did not match.<br /><br />Please try again.", "Password successfully changed!", "Either the username or email address do not exist in our records.", "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.");
        update_option('wpmembers_dialogs', $wpmem_dialogs_arr, '', 'yes');
        // using update_option to allow for forced update
        wpmem_append_tos('new');
        wpmem_append_email();
        // if it's a new install, use the Twenty Twelve stylesheet
        update_option('wpmembers_style', plugin_dir_url(__FILE__) . 'css/generic-no-float.css', '', 'yes');
    } else {
        wpmem_update_captcha();
        wpmem_update_dialogs();
        wpmem_append_email();
        $wpmem_settings = get_option('wpmembers_settings');
        switch (count($wpmem_settings)) {
            case 4:
                // upgrading from 2.2.x
                // update version, insert new toggles, keep other settings
                $wpmem_newsettings = array(WPMEM_VERSION, $wpmem_settings[1], $wpmem_settings[2], '0', '0', '0', '0', '0', '1', '0', '0', $wpmem_settings[3]);
                update_option('wpmembers_settings', $wpmem_newsettings);
                wpmem_append_tos('2.2+');
                wpmem_update_active(0);
                break;
            case 10:
                // count($wpmem_settings) > 4 && count($wpmem_settings) < 12
                // upgrading from 2.3.0, 2.3.1, 2.3.2, 2.4.0, or 2.5.0
                // update version, insert captcha toggle, keep other settings
                $wpmem_newsettings = array(WPMEM_VERSION, $wpmem_settings[1], $wpmem_settings[2], $wpmem_settings[3], $wpmem_settings[4], $wpmem_settings[5], '0', $wpmem_settings[6], '1', $wpmem_settings[7], $wpmem_settings[8], $wpmem_settings[9]);
                update_option('wpmembers_settings', $wpmem_newsettings);
                wpmem_append_tos('2.2+');
                wpmem_update_active($wpmem_settings[5]);
                break;
            case 12:
                // upgrading from 2.5.1 or higher
                // 2.5.1 - 2.9.7 only updated the version
                // 2.9.8 requires a db update, so this allows the admin panel to produce a nag message
                $wpmem_newsettings = array(WPMEM_VERSION, $wpmem_settings[1], $wpmem_settings[2], $wpmem_settings[3], $wpmem_settings[4], $wpmem_settings[5], $wpmem_settings[6], $wpmem_settings[7], $wpmem_settings[8], $wpmem_settings[9], $wpmem_settings[10], $wpmem_settings[11]);
                update_option('wpmembers_settings', $wpmem_newsettings);
                wpmem_update_active($wpmem_settings[5]);
                break;
        }
    }
}
Esempio n. 4
0
/**
 * Handles the various update actions for the default tabs.
 *
 * @since 2.8.0
 *
 * @param  string $action     The action that is being done.
 * @return string $did_update The update message result.
 */
function wpmem_admin_action($action)
{
    $did_update = '';
    // makes sure $did_update is defined
    switch ($action) {
        case 'update_settings':
        case 'update_cpts':
            /**
             * Load Options tab functions.
             */
            include_once WPMEM_PATH . 'admin/tab-options.php';
            $did_update = 'update_cpts' == $action ? wpmem_update_cpts() : wpmem_update_options();
            break;
        case 'update_fields':
        case 'add_field':
        case 'edit_field':
            /**
             * Load Fields tab functions.
             */
            include_once WPMEM_PATH . 'admin/tab-fields.php';
            $did_update = wpmem_update_fields($action);
            break;
        case 'update_dialogs':
            /**
             * Load Dialogs tab functions.
             */
            include_once WPMEM_PATH . 'admin/tab-dialogs.php';
            $did_update = wpmem_update_dialogs();
            break;
        case 'update_emails':
            /**
             * Load Emails tab functions.
             */
            include_once WPMEM_PATH . 'admin/tab-emails.php';
            $did_update = wpmem_update_emails();
            break;
        case 'update_captcha':
            /**
             * Load Captcha tab functions.
             */
            include_once WPMEM_PATH . 'admin/tab-captcha.php';
            $did_update = wpmem_update_captcha();
            break;
    }
    return $did_update;
}
Esempio n. 5
0
/**
 * Handles the various update actions for the default tabs.
 *
 * @since 2.8.0
 *
 * @param  string $action     The action that is being done.
 * @return string $did_update The update message result.
 */
function wpmem_admin_action($action)
{
    $did_update = '';
    // makes sure $did_update is defined
    switch ($action) {
        case 'update_settings':
        case 'update_cpts':
            $did_update = 'update_cpts' == $action ? wpmem_update_cpts() : wpmem_update_options();
            break;
        case 'update_fields':
        case 'add_field':
        case 'edit_field':
            $did_update = wpmem_update_fields($action);
            break;
        case 'update_dialogs':
            $did_update = wpmem_update_dialogs();
            break;
        case 'update_emails':
            $did_update = wpmem_update_emails();
            break;
        case 'update_captcha':
            $did_update = wpmem_update_captcha();
            break;
    }
    return $did_update;
}