コード例 #1
0
ファイル: functions.php プロジェクト: klebercarvalho/demo
/**
 *	abpr_doUpgrade function
 *
 *	Runs when plugin is first activated or if a database/settings update
 *	is needed. Handles
 *
 *	@return void
*/
function abpr_doUpgrade()
{
    global $wp_roles;
    /* First lets make sure the absolute privacy role is set */
    $role = get_role(ABSPRIVACY_ROLEREF);
    if (!$role) {
        add_role(ABSPRIVACY_ROLEREF, ABSPRIVACY_ROLENAME);
    }
    //create the unapproved role
    $options = get_option(ABSPRIVACY_OPTIONS);
    if (!$options) {
        // no options set so set default
        $legacy_options = get_option('absolute_privacy');
        // options term used prior to 2.0
        if ($legacy_options) {
            // user is upgrading from legacy version
            $options['member_lockdown'] = $legacy_options['members_enabled'] == 'yes' ? 'lockdown' : 'off';
            $options['allowed_pages'] = $legacy_options['allowed_pages'];
            $options['pending_welcome_email_subject'] = $legacy_options['pending_welcome_email_subject'];
            $options['pending_welcome_message'] = $legacy_options['pending_welcome_message'];
            $options['account_approval_email_subject'] = $legacy_options['account_approval_email_subject'];
            $options['account_approval_message'] = $legacy_options['account_approval_message'];
            $options['admin_approval_email_subject'] = $legacy_options['admin_approval_email_subject'];
            $options['admin_approval_message'] = $legacy_options['admin_approval_message'];
            $options['redirect_page'] = $legacy_options['redirect_page'];
            $options['admin_block'] = $legacy_options['admin_block'];
            $options['rss_control'] = $legacy_options['rss_control'];
            $options['rss_characters'] = $legacy_options['rss_characters'];
            delete_option('absolute_privacy');
            // delete legacy options from database
            delete_option('absolute_privacy_default');
            /* prior to 2.0 Absolute Privacy changed the default role. 2.0+ no longer does this
             * so we need to change the default role back. For now we'll just change this to subscriber
             */
            $default_role = get_option('default_role');
            if ($default_role == 'unapproved') {
                update_option('default_role', 'subscriber');
            }
        } else {
            // user must be installing fresh since no options were found
            $options['member_lockdown'] = 'off';
            $options['rss_control'] = 'off';
            $options['pending_welcome_email_subject'] = 'Your account with ' . stripslashes(get_option('blogname')) . ' is under review';
            $options['pending_welcome_message'] = "Hi %name%, \n \n Thanks for registering for %blogname%! Your registration is currently being reviewed. You will not be able to login until it has been approved. You will receive an email at that time. Thanks for your patience. \n \n Sincerely, \n \n %blogname%";
            $options['account_approval_email_subject'] = "Your account has been approved!";
            $options['account_approval_message'] = "Your registration with %blogname% has been approved! \n \n You may login using the following information: \n Username: %username% \n Password: (hidden) \n URL: %login_url%";
            $options['admin_approval_email_subject'] = "A new user is waiting approval";
            $options['admin_approval_message'] = "A new user has registered for %blogname% and is waiting your approval. You may approve or delete them here: %approval_url% \n \n This user cannot log in until you approve them.";
        }
        update_option(ABSPRIVACY_OPTIONS, $options);
        // set option values
        update_option(ABSPRIVACY_DBOPTION, ABSPRIVACY_DBVERSION);
    } else {
        // there are $options already in the database
        if (abpr_needsUpgrade()) {
            /* Run options upgrade script here */
            // for now lets just enter the DB version
            update_option(ABSPRIVACY_DBOPTION, ABSPRIVACY_DBVERSION);
        }
    }
}
コード例 #2
0
    return;
}
// Wireup actions
add_action('init', 'absprivacy_init');
// Initialize textdomain
add_action('template_redirect', 'abpr_lockDown');
// lock down website
add_action('init', 'abpr_adminLockDown', 0);
// lock down admin area
add_action('register_form', 'abpr_registrationBox');
// adds password field & first/last name to registration box
add_action('user_register', 'abpr_addNewUser');
// adds registration info to database
if (isset($_GET['action']) && $_GET['action'] == 'register') {
    add_action('login_head', 'abpr_regCSS');
    //adds registration form CSS
}
if (abpr_needsUpgrade()) {
    add_action('admin_notices', 'abpr_adminnotice');
}
// Wireup filters
add_filter('the_content', 'abpr_check_is_feed');
// filter content for feeds
add_filter('registration_errors', 'abpr_checkRegErrors');
// adds registration form error checks
add_filter('authenticate', 'abpr_authenticateUser', 10, 3);
// authenticate new user
add_filter('password_reset_message', 'abpr_profileRecoveryLink', 10, 2);
// Wireup shortcodes
add_shortcode('loginform', 'abpr_loginShortcode');
add_shortcode('profilepage', 'abpr_profileShortcode');